Compare commits
No commits in common. "master" and "no-auto-scroll" have entirely different histories.
master
...
no-auto-sc
340 changed files with 92745 additions and 117831 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,7 +2,6 @@
|
|||
.DS_Store
|
||||
*.swp
|
||||
*.tmp
|
||||
*~
|
||||
|
||||
# Project files that should not be in the repo
|
||||
.*
|
||||
|
|
|
|||
4
.gitmodules
vendored
4
.gitmodules
vendored
|
|
@ -1,6 +1,6 @@
|
|||
[submodule "doc/wiki"]
|
||||
path = doc/wiki
|
||||
url = https://github.com/ajaxorg/ace.wiki.git
|
||||
url = git://github.com/ajaxorg/ace.wiki.git
|
||||
[submodule "build"]
|
||||
path = build
|
||||
url = https://github.com/ajaxorg/ace-builds.git
|
||||
url = git://github.com/ajaxorg/ace-builds.git
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
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.
|
||||
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.
|
||||
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://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
|
||||
|
|
@ -1,48 +1,3 @@
|
|||
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
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ function demo() {
|
|||
|
||||
function changeComments(data) {
|
||||
return (data
|
||||
.replace("doc/site/images/ace-logo.png", "demo/kitchen-sink/ace-logo.png")
|
||||
.replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
|
||||
.replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
|
||||
.replace(/\/\*DEVEL[\d\D]*?DEVEL\*\//g, "")
|
||||
|
|
@ -185,7 +184,7 @@ function jsFileList(path, filter) {
|
|||
filter = /_test/;
|
||||
|
||||
return fs.readdirSync(path).map(function(x) {
|
||||
if (x.slice(-3) == ".js" && !filter.test(x) && !/\s|BASE|(\b|_)dummy(\b|_)/.test(x))
|
||||
if (x.slice(-3) == ".js" && !filter.test(x) && !/\s/.test(x))
|
||||
return x.slice(0, -3);
|
||||
}).filter(Boolean);
|
||||
}
|
||||
|
|
@ -307,7 +306,6 @@ function buildAceModuleInternal(opts, callback) {
|
|||
ignore: opts.ignore || [],
|
||||
withRequire: false,
|
||||
basepath: ACE_HOME,
|
||||
transforms: [normalizeLineEndings],
|
||||
afterRead: [optimizeTextModules]
|
||||
}, write);
|
||||
}
|
||||
|
|
@ -361,7 +359,7 @@ function buildAce(options) {
|
|||
buildSubmodule(options, {
|
||||
projectType: "theme",
|
||||
require: ["ace/theme/" + name]
|
||||
}, "theme-" + name);
|
||||
}, "theme-" + name.replace("_theme", ""));
|
||||
});
|
||||
// keybindings
|
||||
["vim", "emacs"].forEach(function(name) {
|
||||
|
|
@ -408,10 +406,6 @@ function getLoadedFileList(options, callback, result) {
|
|||
callback(Object.keys(deps));
|
||||
}
|
||||
|
||||
function normalizeLineEndings(module) {
|
||||
module.source = module.source.replace(/\r\n/g, "\n");
|
||||
}
|
||||
|
||||
function optimizeTextModules(sources) {
|
||||
var textModules = {};
|
||||
return sources.filter(function(pkg) {
|
||||
|
|
@ -457,10 +451,10 @@ function optimizeTextModules(sources) {
|
|||
if (/\.css$/.test(pkg.id)) {
|
||||
// remove unnecessary whitespace from css
|
||||
input = input.replace(/\n\s+/g, "\n");
|
||||
input = '"' + input.replace(/\n/g, '\\\n') + '"';
|
||||
input = '"' + input.replace(/\r?\n/g, '\\\n') + '"';
|
||||
} else {
|
||||
// but don't break other files!
|
||||
input = '"' + input.replace(/\n/g, '\\n\\\n') + '"';
|
||||
input = '"' + input.replace(/\r?\n/g, '\\n\\\n') + '"';
|
||||
}
|
||||
textModules[pkg.id] = input;
|
||||
}
|
||||
|
|
@ -508,7 +502,7 @@ function exportAce(ns, modules, requireBase, extModules) {
|
|||
if (typeof modules == "string")
|
||||
modules = [modules];
|
||||
|
||||
return (text.replace(/;\s*$/, "") + ";" + template
|
||||
return (text + ";" + template
|
||||
.toString()
|
||||
.replace(/MODULES/g, JSON.stringify(modules))
|
||||
.replace(/REQUIRE_NS/g, requireBase)
|
||||
|
|
@ -542,7 +536,7 @@ function generateThemesModule(themes) {
|
|||
function addSnippetFile(modeName) {
|
||||
var snippetFilePath = ACE_HOME + "/lib/ace/snippets/" + modeName;
|
||||
if (!fs.existsSync(snippetFilePath + ".js")) {
|
||||
copy.file(ACE_HOME + "/tool/templates/snippets.js", snippetFilePath + ".js", function(t) {
|
||||
copy.file(ACE_HOME + "/tool/snippets.tmpl.js", snippetFilePath + ".js", function(t) {
|
||||
return t.replace(/%modeName%/g, modeName);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
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
|
||||
-------------
|
||||
|
|
@ -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:
|
||||
|
||||
```javascript
|
||||
var JavaScriptMode = ace.require("ace/mode/javascript").Mode;
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
editor.getSession().setMode(new JavaScriptMode());
|
||||
```
|
||||
|
||||
|
|
|
|||
158
api/editor.html
158
api/editor.html
|
|
@ -390,8 +390,8 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -444,7 +444,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -471,7 +471,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -498,7 +498,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -525,7 +525,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -564,7 +564,7 @@
|
|||
<ul class="signatures">
|
||||
<li class="signature">
|
||||
<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 class="metaInfo">
|
||||
</ul>
|
||||
|
|
@ -577,7 +577,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -610,7 +610,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -920,9 +920,9 @@
|
|||
</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>
|
||||
|
||||
<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 ">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>
|
||||
<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 ">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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -954,9 +954,9 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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 ">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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -983,8 +983,8 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1011,8 +1011,8 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1064,8 +1064,8 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1523,8 +1523,8 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1966,9 +1966,9 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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 ">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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2070,7 +2070,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2132,7 +2132,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2164,7 +2164,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2191,7 +2191,7 @@
|
|||
</div>
|
||||
<div class="description"><p>Moves the cursor'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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2218,7 +2218,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2245,8 +2245,8 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2273,7 +2273,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2384,7 +2384,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2461,7 +2461,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2538,7 +2538,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2565,8 +2565,8 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2593,7 +2593,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3105,7 +3105,7 @@
|
|||
</div>
|
||||
<div class="description"><p>Called whenever a text "paste" 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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3277,7 +3277,7 @@
|
|||
</div>
|
||||
<div class="description"><p>Removes words of text from the editor. A "word" 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 "left" or "right"</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 "left" or "right"</p>
|
||||
</td></tr></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3329,7 +3329,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3456,8 +3456,8 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3484,8 +3484,8 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3512,7 +3512,7 @@
|
|||
</div>
|
||||
<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'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't changed</p>
|
||||
</td></tr></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3613,10 +3613,10 @@
|
|||
</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>
|
||||
|
||||
<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 ">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>
|
||||
<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 ">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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3643,7 +3643,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3695,8 +3695,8 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3723,8 +3723,8 @@
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3825,7 +3825,7 @@
|
|||
</div>
|
||||
<div class="description"><p>Specifies whether to use behaviors or not. "Behaviors" 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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3876,7 +3876,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3927,7 +3927,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3954,7 +3954,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4005,7 +4005,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4032,7 +4032,7 @@
|
|||
</div>
|
||||
<div class="description"><p>Sets a new key handler, such as "vim" or "windows".</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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4059,7 +4059,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4086,7 +4086,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4113,7 +4113,7 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4140,7 +4140,7 @@
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4170,7 +4170,7 @@
|
|||
although this code change in the future.</p>
|
||||
<p>This function also emits the <code>'changeSelectionStyle'</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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4197,7 +4197,7 @@ although this code change in the future.</p>
|
|||
</div>
|
||||
<div class="description"><p>Sets a new editsession to use. This method also emits the <code>'changeSession'</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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4224,7 +4224,7 @@ although this code change in the future.</p>
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4251,7 +4251,7 @@ although this code change in the future.</p>
|
|||
</div>
|
||||
<div class="description"><p>If <code>showInvisibles</code> is set to <code>true</code>, invisible characters—like spaces or new lines—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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4278,7 +4278,7 @@ although this code change in the future.</p>
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4305,7 +4305,7 @@ although this code change in the future.</p>
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4332,7 +4332,7 @@ although this code change in the future.</p>
|
|||
</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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4364,8 +4364,8 @@ although this code change in the future.</p>
|
|||
</div>
|
||||
<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>
|
||||
</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>
|
||||
<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></table>
|
||||
</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
|
||||
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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4595,7 +4595,7 @@ when such a character is typed in.</p>
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4647,7 +4647,7 @@ when such a character is typed in.</p>
|
|||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@
|
|||
<article id="Selection" data-title="Selection (class)" class="article">
|
||||
<div class="section description">
|
||||
<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>
|
||||
|
|
@ -1778,4 +1778,4 @@
|
|||
<script defer src="./resources/javascripts/disqus-ext.js"></script>
|
||||
<script defer src="./resources/javascripts/ga.js"></script>
|
||||
<div id="disqus_thread"></div>
|
||||
</div>
|
||||
</div>
|
||||
2
build
2
build
|
|
@ -1 +1 @@
|
|||
Subproject commit a4e495d8901876c6bafe3870a35cb8e32c827e97
|
||||
Subproject commit cbc08e4ebc4843eebec8dcd213751cb0d64c955b
|
||||
|
|
@ -51,7 +51,7 @@ function foo() {
|
|||
|
||||
function inject(options, callback) {
|
||||
var baseUrl = options.baseUrl || "../../src-noconflict";
|
||||
|
||||
|
||||
var load = function(path, callback) {
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var s = document.createElement('script');
|
||||
|
|
@ -87,7 +87,7 @@ function inject(options, callback) {
|
|||
// Call the inject function to load the ace files.
|
||||
var textAce;
|
||||
inject({}, function () {
|
||||
// Transform the textarea on the page into an ace editor.
|
||||
// Transform the textarea on the page into an ace editor.
|
||||
var t = document.querySelector("textarea");
|
||||
textAce = ace.require("ace/ext/textarea").transformTextarea(t);
|
||||
setTimeout(function(){textAce.setDisplaySettings(true)});
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#editor {
|
||||
|
||||
#editor {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
alert("Ace Rocks " + items[i]);
|
||||
}
|
||||
}</pre>
|
||||
|
||||
|
||||
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script>
|
||||
var editor = ace.edit("editor");
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* 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
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* * 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
|
||||
|
|
@ -38,62 +38,69 @@
|
|||
|
||||
var ACE_NAMESPACE = "";
|
||||
|
||||
var global = (function() { return this; })();
|
||||
if (!global && typeof window != "undefined") global = window; // strict mode
|
||||
var global = (function() {
|
||||
return this;
|
||||
})();
|
||||
|
||||
|
||||
if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
|
||||
return;
|
||||
|
||||
|
||||
var define = function(module, deps, payload) {
|
||||
if (typeof module !== "string") {
|
||||
if (define.original)
|
||||
define.original.apply(this, arguments);
|
||||
var _define = function(module, deps, payload) {
|
||||
if (typeof module !== 'string') {
|
||||
if (_define.original)
|
||||
_define.original.apply(window, arguments);
|
||||
else {
|
||||
console.error("dropping module because define wasn\'t a string.");
|
||||
console.error('dropping module because define wasn\'t a string.');
|
||||
console.trace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (arguments.length == 2)
|
||||
payload = deps;
|
||||
if (!define.modules[module]) {
|
||||
define.payloads[module] = payload;
|
||||
define.modules[module] = null;
|
||||
}
|
||||
};
|
||||
|
||||
define.modules = {};
|
||||
define.payloads = {};
|
||||
if (!_define.modules) {
|
||||
_define.modules = {};
|
||||
_define.payloads = {};
|
||||
}
|
||||
|
||||
_define.payloads[module] = payload;
|
||||
_define.modules[module] = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get at functionality define()ed using the function above
|
||||
*/
|
||||
var _require = function(parentId, module, callback) {
|
||||
if (typeof module === "string") {
|
||||
var payload = lookup(parentId, module);
|
||||
if (payload != undefined) {
|
||||
callback && callback();
|
||||
return payload;
|
||||
}
|
||||
} else if (Object.prototype.toString.call(module) === "[object Array]") {
|
||||
if (Object.prototype.toString.call(module) === "[object Array]") {
|
||||
var params = [];
|
||||
for (var i = 0, l = module.length; i < l; ++i) {
|
||||
var dep = lookup(parentId, module[i]);
|
||||
if (dep == undefined && require.original)
|
||||
return;
|
||||
if (!dep && _require.original)
|
||||
return _require.original.apply(window, arguments);
|
||||
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) {
|
||||
var packagedModule = _require("", module, callback);
|
||||
if (packagedModule == undefined && require.original)
|
||||
return require.original.apply(this, arguments);
|
||||
return packagedModule;
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
return payload;
|
||||
}
|
||||
else {
|
||||
if (_require.original)
|
||||
return _require.original.apply(window, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
var normalizeModule = function(parentId, moduleName) {
|
||||
|
|
@ -112,6 +119,7 @@ var normalizeModule = function(parentId, moduleName) {
|
|||
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
|
||||
}
|
||||
}
|
||||
|
||||
return moduleName;
|
||||
};
|
||||
|
||||
|
|
@ -120,11 +128,12 @@ var normalizeModule = function(parentId, moduleName) {
|
|||
* definition function if needed.
|
||||
*/
|
||||
var lookup = function(parentId, moduleName) {
|
||||
|
||||
moduleName = normalizeModule(parentId, moduleName);
|
||||
|
||||
var module = define.modules[moduleName];
|
||||
var module = _define.modules[moduleName];
|
||||
if (!module) {
|
||||
module = define.payloads[moduleName];
|
||||
module = _define.payloads[moduleName];
|
||||
if (typeof module === 'function') {
|
||||
var exports = {};
|
||||
var mod = {
|
||||
|
|
@ -140,15 +149,19 @@ var lookup = function(parentId, moduleName) {
|
|||
|
||||
var returnValue = module(req, exports, mod);
|
||||
exports = returnValue || mod.exports;
|
||||
define.modules[moduleName] = exports;
|
||||
delete define.payloads[moduleName];
|
||||
_define.modules[moduleName] = exports;
|
||||
delete _define.payloads[moduleName];
|
||||
}
|
||||
module = define.modules[moduleName] = exports || module;
|
||||
module = _define.modules[moduleName] = exports || module;
|
||||
}
|
||||
return module;
|
||||
};
|
||||
|
||||
function exportAce(ns) {
|
||||
var require = function(module, callback) {
|
||||
return _require("", module, callback);
|
||||
};
|
||||
|
||||
var root = global;
|
||||
if (ns) {
|
||||
if (!global[ns])
|
||||
|
|
@ -157,13 +170,13 @@ function exportAce(ns) {
|
|||
}
|
||||
|
||||
if (!root.define || !root.define.packaged) {
|
||||
define.original = root.define;
|
||||
root.define = define;
|
||||
_define.original = root.define;
|
||||
root.define = _define;
|
||||
root.define.packaged = true;
|
||||
}
|
||||
|
||||
if (!root.require || !root.require.packaged) {
|
||||
require.original = root.require;
|
||||
_require.original = root.require;
|
||||
root.require = require;
|
||||
root.require.packaged = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ body {
|
|||
margin:0;
|
||||
padding:0;
|
||||
background-color:#e6f5fc;
|
||||
|
||||
|
||||
}
|
||||
|
||||
H2, H3, H4 {
|
||||
|
|
@ -58,7 +58,7 @@ PRE{
|
|||
position:relative;
|
||||
overflow:hidden;
|
||||
background: url(images/background.png) repeat-x 0 0;
|
||||
border-bottom:1px solid #c9e8fa;
|
||||
border-bottom:1px solid #c9e8fa;
|
||||
}
|
||||
|
||||
#header .content .signature {
|
||||
|
|
@ -224,3 +224,7 @@ UL.menu-footer LI A {
|
|||
UL.menu-footer LI A:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@
|
|||
<style type="text/css" media="screen">
|
||||
|
||||
.ace_editor {
|
||||
position: relative !important;
|
||||
border: 1px solid lightgray;
|
||||
margin: auto;
|
||||
height: 200px;
|
||||
width: 80%;
|
||||
}
|
||||
.scrollmargin {
|
||||
height: 80px;
|
||||
height: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -23,8 +24,6 @@
|
|||
<div class="scrollmargin"></div>
|
||||
<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>
|
||||
|
|
@ -47,13 +46,6 @@ require(["ace/ace"], function(ace) {
|
|||
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");
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<pre id="editor"></pre>
|
||||
|
||||
<!-- load emmet code and snippets compiled for browser -->
|
||||
<script src="https://cloud9ide.github.io/emmet-core/emmet.js"></script>
|
||||
<script src="https://nightwing.github.io/emmet-core/emmet.js"></script>
|
||||
|
||||
<script src="kitchen-sink/require.js"></script>
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -531,7 +531,7 @@ new StatusBar(env.editor, cmdLine.container);
|
|||
|
||||
|
||||
var Emmet = require("ace/ext/emmet");
|
||||
net.loadScript("https://cloud9ide.github.io/emmet-core/emmet.js", function() {
|
||||
net.loadScript("https://nightwing.github.io/emmet-core/emmet.js", function() {
|
||||
Emmet.setCore(window.emmet);
|
||||
env.editor.setOption("enableEmmet", true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -29,17 +29,13 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
var dom = require("ace/lib/dom");
|
||||
var Range = require("ace/range").Range;
|
||||
// allow easy access to ace in console, but not in ace code which uses strict
|
||||
function isStrict() {
|
||||
try { return !arguments.callee.caller.caller.caller}
|
||||
catch(e){ return true }
|
||||
}
|
||||
function warn() {
|
||||
var s = (new Error()).stack || "";
|
||||
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)) {
|
||||
if (isStrict()) {
|
||||
console.error("trying to access to global variable");
|
||||
}
|
||||
}
|
||||
|
|
@ -63,155 +59,21 @@ def(window, "session", function(){ warn(); return window.env.editor.session });
|
|||
def(window, "split", function(){ warn(); return window.env.split });
|
||||
|
||||
|
||||
def(window, "devUtil", function(){ warn(); return exports });
|
||||
exports.showTextArea = function(argument) {
|
||||
dom.importCssString("\
|
||||
.ace_text-input {\
|
||||
position: absolute;\
|
||||
z-index: 10!important;\
|
||||
width: 6em!important;\
|
||||
height: 1em;\
|
||||
opacity: 1!important;\
|
||||
background: rgba(0, 92, 255, 0.11);\
|
||||
border: none;\
|
||||
font: inherit;\
|
||||
padding: 0 1px;\
|
||||
margin: 0 -1px;\
|
||||
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";
|
||||
};
|
||||
};
|
||||
|
||||
/* for textinput debuggging
|
||||
dom.importCssString("\
|
||||
.ace_text-input {\
|
||||
position: absolute;\
|
||||
z-index: 10!important;\
|
||||
width: 6em!important;\
|
||||
height: 1em;\
|
||||
opacity: 1!important;\
|
||||
background: rgba(0, 92, 255, 0.11);\
|
||||
border: none;\
|
||||
font: inherit;\
|
||||
padding: 0 1px;\
|
||||
margin: 0 -1px;\
|
||||
text-indent: 0em;\
|
||||
}\
|
||||
")*/
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -86,12 +86,9 @@ var ownSource = {
|
|||
/* filled from require*/
|
||||
};
|
||||
|
||||
var hugeDocs = require.toUrl ? {
|
||||
var hugeDocs = {
|
||||
"build/src/ace.js": "",
|
||||
"build/src-min/ace.js": ""
|
||||
} : {
|
||||
"src/ace.js": "",
|
||||
"src-min/ace.js": ""
|
||||
};
|
||||
|
||||
modelist.modes.forEach(function(m) {
|
||||
|
|
@ -169,44 +166,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 = {
|
||||
fileCache: fileCache,
|
||||
docs: sort(prepareDocList(docs)),
|
||||
ownSource: prepareDocList(ownSource),
|
||||
hugeDocs: prepareDocList(hugeDocs),
|
||||
initDoc: initDoc,
|
||||
loadDoc: loadDoc,
|
||||
saveDoc: saveDoc,
|
||||
loadDoc: loadDoc
|
||||
};
|
||||
module.exports.all = {
|
||||
"Mode Examples": module.exports.docs,
|
||||
|
|
|
|||
|
|
@ -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_.
|
||||
|
|
@ -1,18 +1,28 @@
|
|||
.text-layer {
|
||||
font: 12px Monaco, "Courier New", monospace;
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 12pX;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.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 {
|
||||
0%, 40% {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
40.5%, 100% {
|
||||
40% {
|
||||
opacity: 0;
|
||||
}
|
||||
40.5% {
|
||||
opacity: 1
|
||||
}
|
||||
100% {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
@ -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
|
||||
%
|
||||
|
|
@ -3,6 +3,6 @@
|
|||
<div id="comments">
|
||||
{{#each comments}}
|
||||
<h2><a href="/posts/{{../permalink}}#{{id}}">{{title}}</a></h2>
|
||||
<div>{{{body}}}</div>
|
||||
<div>{{body}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
)
|
||||
|
|
@ -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
|
||||
|
|
@ -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]"
|
||||
|
|
@ -1,17 +1 @@
|
|||
%{
|
||||
%{
|
||||
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'
|
||||
TODO
|
||||
|
|
@ -20,7 +20,7 @@ class Range
|
|||
end
|
||||
end
|
||||
|
||||
{:id => ?", :key => "value"}
|
||||
{:id => 34, :key => "value"}
|
||||
|
||||
|
||||
herDocs = [<<'FOO', <<BAR, <<-BAZ, <<-`EXEC`] #comment
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
# Script to open a browser to current branch
|
||||
# Repo formats:
|
||||
# ssh git@github.com:richo/gh_pr.git
|
||||
# http https://richoH@github.com/richo/gh_pr.git
|
||||
# git git://github.com/richo/gh_pr.git
|
||||
# ssh git@github.com:richoH/gh_pr.git
|
||||
# http https://richoH@github.com/richoH/gh_pr.git
|
||||
# git git://github.com/richoH/gh_pr.git
|
||||
|
||||
username=`git config --get github.user`
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -53,16 +53,16 @@ require("ace/commands/default_commands").commands.push({
|
|||
return;
|
||||
}
|
||||
|
||||
var rowCount = 10;
|
||||
var rowCount = 10;
|
||||
var w = {
|
||||
row: row,
|
||||
// rowCount: rowCount,
|
||||
fixedWidth: true,
|
||||
el: dom.createElement("div"),
|
||||
editor: inlineEditor
|
||||
editor: editor
|
||||
};
|
||||
var el = w.el;
|
||||
el.appendChild(inlineEditor.container);
|
||||
el.appendChild(inlineEditor.container);
|
||||
|
||||
if (!editor.session.widgetManager) {
|
||||
editor.session.widgetManager = new LineWidgets(editor.session);
|
||||
|
|
@ -96,6 +96,9 @@ require("ace/commands/default_commands").commands.push({
|
|||
|
||||
editor.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");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ exports.singleLineEditor = function(el) {
|
|||
|
||||
renderer.setStyle("ace_one-line");
|
||||
var editor = new Editor(renderer);
|
||||
new MultiSelect(editor);
|
||||
editor.session.setUndoManager(new UndoManager());
|
||||
|
||||
editor.setShowPrintMargin(false);
|
||||
|
|
|
|||
|
|
@ -46,10 +46,4 @@ body {
|
|||
position: absolute;
|
||||
right: 0;
|
||||
border-left: 1px solid;
|
||||
}
|
||||
|
||||
/* .ace_text-input {
|
||||
z-index: 10!important;
|
||||
opacity: 1!important;
|
||||
background: rgb(84, 0, 255)!important;
|
||||
}*/
|
||||
}
|
||||
|
|
@ -2,13 +2,13 @@
|
|||
<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">
|
||||
<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;
|
||||
border: solid lightgrey 1px
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
|
@ -21,8 +21,9 @@
|
|||
<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;
|
||||
border: solid lightgrey 1px
|
||||
}
|
||||
|
||||
</div>
|
||||
|
|
@ -34,26 +35,6 @@ function wobble (flam) {
|
|||
|
||||
</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"}});
|
||||
|
|
|
|||
|
|
@ -2,13 +2,15 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
// $'
|
||||
// include ace search path and modules
|
||||
require("amd-loader");
|
||||
|
||||
// load jsdom, which is required by Ace
|
||||
require("../../lib/ace/test/mockdom");
|
||||
|
||||
var http = require("http");
|
||||
var fs = require("fs");
|
||||
var resolve = require("path").resolve;
|
||||
|
||||
// load the highlighter and the desired mode and theme
|
||||
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;
|
||||
|
||||
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"});
|
||||
fs.readFile(path, "utf8", function(err, data) {
|
||||
if (err) data = err.message;
|
||||
fs.readFile(__filename, "utf8", function(err, data) {
|
||||
var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
|
||||
res.end(
|
||||
'<html><body>\n' +
|
||||
'<style type="text/css" media="screen">\n' +
|
||||
highlighted.css +
|
||||
'</style>\n' +
|
||||
highlighted.html +
|
||||
highlighted.html +
|
||||
'</body></html>'
|
||||
);
|
||||
});
|
||||
|
|
|
|||
BIN
doc/Contributor_License_Agreement-v2.pdf
Normal file
BIN
doc/Contributor_License_Agreement-v2.pdf
Normal file
Binary file not shown.
BIN
doc/Corporate_Contributor_License_Agreement-v2.pdf
Normal file
BIN
doc/Corporate_Contributor_License_Agreement-v2.pdf
Normal file
Binary file not shown.
BIN
doc/site/images/lws-logo.png
Normal file
BIN
doc/site/images/lws-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
|
|
@ -1,49 +1,39 @@
|
|||
var editor;
|
||||
var embedded_editor;
|
||||
$(function() {
|
||||
if (typeof ace !== "undefined") {
|
||||
ace.config.set("workerPath", "build/src-min");
|
||||
editor = ace.edit("ace_editor_demo");
|
||||
editor.container.style.opacity = "";
|
||||
embedded_editor = ace.edit("embedded_ace_code");
|
||||
embedded_editor.container.style.opacity = "";
|
||||
embedded_editor.session.setMode("ace/mode/html");
|
||||
embedded_editor.setAutoScrollEditorIntoView(true);
|
||||
embedded_editor.setOption("maxLines", 40);
|
||||
|
||||
ace.config.set("workerPath", "build/src-min");
|
||||
editor = ace.edit("ace_editor_demo");
|
||||
editor.container.style.opacity = "";
|
||||
embedded_editor = ace.edit("embedded_ace_code");
|
||||
embedded_editor.container.style.opacity = "";
|
||||
embedded_editor.session.setMode("ace/mode/html");
|
||||
embedded_editor.setAutoScrollEditorIntoView(true);
|
||||
embedded_editor.setOption("maxLines", 40);
|
||||
|
||||
editor.setOptions({
|
||||
maxLines: 30,
|
||||
mode: "ace/mode/javascript",
|
||||
autoScrollEditorIntoView: true
|
||||
});
|
||||
|
||||
ace.config.loadModule("ace/ext/emmet", function() {
|
||||
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/language_tools", function() {
|
||||
embedded_editor.setOptions({
|
||||
enableSnippets: true,
|
||||
enableBasicAutocompletion: true
|
||||
});
|
||||
editor.setOptions({
|
||||
maxLines: 30,
|
||||
mode: "ace/mode/javascript",
|
||||
autoScrollEditorIntoView: true
|
||||
enableSnippets: true,
|
||||
enableBasicAutocompletion: true
|
||||
});
|
||||
|
||||
ace.config.loadModule("ace/ext/emmet", function() {
|
||||
ace.require("ace/lib/net").loadScript("http://cloud9ide.github.io/emmet-core/emmet.js", function() {
|
||||
embedded_editor.setOption("enableEmmet", 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();
|
||||
|
|
@ -147,22 +137,22 @@ $(function() {
|
|||
});
|
||||
});
|
||||
|
||||
$(window).on("hashchange", function(e) {
|
||||
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
|
||||
tabs.each(function() {
|
||||
$(window).on("hashchange", function(e) {
|
||||
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
|
||||
tabs.each(function() {
|
||||
var idx = $.bbq.getState("nav") || "about";
|
||||
var section = e.fragment.split("&")[1] || "";
|
||||
$(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click');
|
||||
|
||||
|
||||
// handles dropping in from new link
|
||||
var api = $.bbq.getState("api");
|
||||
if (api) {
|
||||
$(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 dom = ace.require("ace/lib/dom")
|
||||
function qsa(sel) {
|
||||
var els = document.querySelectorAll(sel);
|
||||
var result = [];
|
||||
for (var i = 0, l = els.length; i < l; i++)
|
||||
result[i] = els[i];
|
||||
return result;
|
||||
return Array.apply(null, document.querySelectorAll(sel));
|
||||
}
|
||||
|
||||
qsa("code[class]").forEach(function(el) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
192
index.html
192
index.html
File diff suppressed because one or more lines are too long
|
|
@ -257,9 +257,7 @@
|
|||
<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;">
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ exports.edit = function(el) {
|
|||
event.addListener(window, "resize", env.onResize);
|
||||
editor.on("destroy", function() {
|
||||
event.removeListener(window, "resize", env.onResize);
|
||||
env.editor.container.env = null; // prevent memory leak on old ie
|
||||
});
|
||||
editor.container.env = editor.env = env;
|
||||
return editor;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
**/
|
||||
|
|
@ -99,54 +99,72 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
|||
* - `value`: An object describing the new Anchor position
|
||||
*
|
||||
**/
|
||||
this.onChange = function(delta) {
|
||||
if (delta.start.row == delta.end.row && delta.start.row != this.row)
|
||||
this.onChange = function(e) {
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
|
||||
if (range.start.row == range.end.row && range.start.row != this.row)
|
||||
return;
|
||||
|
||||
if (delta.start.row > this.row)
|
||||
if (range.start.row > this.row)
|
||||
return;
|
||||
|
||||
var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
|
||||
this.setPosition(point.row, point.column, true);
|
||||
|
||||
if (range.start.row == this.row && range.start.column > this.column)
|
||||
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 && column === 0 && this.$insertRight) {
|
||||
// do nothing
|
||||
}
|
||||
else 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.
|
||||
|
|
@ -183,7 +201,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
|||
};
|
||||
|
||||
/**
|
||||
* When called, the `"change"` event listener is removed.
|
||||
* When called, the `'change'` event listener is removed.
|
||||
*
|
||||
**/
|
||||
this.detach = function() {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ module.exports = {
|
|||
var doc = new Document("juhu\nkinners");
|
||||
var anchor = new Anchor(doc, 1, 4);
|
||||
|
||||
doc.insertFullLines(1, ["123", "456"]);
|
||||
doc.insertLines(1, ["123", "456"]);
|
||||
assert.position(anchor.getPosition(), 3, 4);
|
||||
},
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ module.exports = {
|
|||
var doc = new Document("juhu\nkinners");
|
||||
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);
|
||||
},
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ module.exports = {
|
|||
var doc = new Document("juhu\nkinners");
|
||||
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);
|
||||
},
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ module.exports = {
|
|||
var doc = new Document("juhu\n1\n2\nkinners");
|
||||
var anchor = new Anchor(doc, 3, 4);
|
||||
|
||||
doc.removeFullLines(1, 2);
|
||||
doc.removeLines(1, 2);
|
||||
assert.position(anchor.getPosition(), 1, 4);
|
||||
},
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ module.exports = {
|
|||
var doc = new Document("juhu\nkinners\n123");
|
||||
var anchor = new Anchor(doc, 1, 5);
|
||||
|
||||
doc.removeFullLines(1, 1);
|
||||
doc.removeLines(1, 1);
|
||||
assert.position(anchor.getPosition(), 1, 0);
|
||||
},
|
||||
|
||||
|
|
@ -208,9 +208,9 @@ module.exports = {
|
|||
var doc = new Document("juhu\nkinners\n123");
|
||||
var anchor = new Anchor(doc, 2, 4);
|
||||
|
||||
doc.removeFullLines(0, 3);
|
||||
doc.removeLines(0, 3);
|
||||
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.equal(doc.getValue(), "a\nb\nc\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -36,14 +36,11 @@ var AcePopup = require("./autocomplete/popup").AcePopup;
|
|||
var util = require("./autocomplete/util");
|
||||
var event = require("./lib/event");
|
||||
var lang = require("./lib/lang");
|
||||
var dom = require("./lib/dom");
|
||||
var snippetManager = require("./snippets").snippetManager;
|
||||
|
||||
var Autocomplete = function() {
|
||||
this.autoInsert = false;
|
||||
this.autoInsert = true;
|
||||
this.autoSelect = true;
|
||||
this.exactMatch = false;
|
||||
this.gatherCompletionsId = 0;
|
||||
this.keyboardHandler = new HashHandler();
|
||||
this.keyboardHandler.bindKeys(this.commands);
|
||||
|
||||
|
|
@ -55,11 +52,10 @@ var Autocomplete = function() {
|
|||
this.changeTimer = lang.delayedCall(function() {
|
||||
this.updateCompletions(true);
|
||||
}.bind(this));
|
||||
|
||||
this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
|
||||
};
|
||||
|
||||
(function() {
|
||||
this.gatherCompletionsId = 0;
|
||||
|
||||
this.$init = function() {
|
||||
this.popup = new AcePopup(document.body || document.documentElement);
|
||||
|
|
@ -68,14 +64,6 @@ var Autocomplete = function() {
|
|||
e.stop();
|
||||
}.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) {
|
||||
|
|
@ -84,8 +72,6 @@ var Autocomplete = function() {
|
|||
|
||||
this.popup.setData(this.completions.filtered);
|
||||
|
||||
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
||||
|
||||
var renderer = editor.renderer;
|
||||
this.popup.setRow(this.autoSelect ? 0 : -1);
|
||||
if (!keepPopupPosition) {
|
||||
|
|
@ -100,11 +86,9 @@ var Autocomplete = function() {
|
|||
var rect = editor.container.getBoundingClientRect();
|
||||
pos.top += rect.top - renderer.layerConfig.offset;
|
||||
pos.left += rect.left - editor.renderer.scrollLeft;
|
||||
pos.left += renderer.gutterWidth;
|
||||
pos.left += renderer.$gutterLayer.gutterWidth;
|
||||
|
||||
this.popup.show(pos, lineHeight);
|
||||
} else if (keepPopupPosition && !prefix) {
|
||||
this.detach();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -115,12 +99,12 @@ var Autocomplete = function() {
|
|||
this.editor.off("mousedown", this.mousedownListener);
|
||||
this.editor.off("mousewheel", this.mousewheelListener);
|
||||
this.changeTimer.cancel();
|
||||
this.hideDocTooltip();
|
||||
|
||||
this.gatherCompletionsId += 1;
|
||||
if (this.popup && this.popup.isOpen)
|
||||
if (this.popup && this.popup.isOpen) {
|
||||
this.gatherCompletionsId += 1;
|
||||
this.popup.hide();
|
||||
|
||||
}
|
||||
|
||||
if (this.base)
|
||||
this.base.detach();
|
||||
this.activated = false;
|
||||
|
|
@ -138,18 +122,12 @@ var Autocomplete = function() {
|
|||
this.detach();
|
||||
};
|
||||
|
||||
this.blurListener = function(e) {
|
||||
this.blurListener = function() {
|
||||
// we have to check if activeElement is a child of popup because
|
||||
// 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
|
||||
) {
|
||||
if (el != this.editor.textInput.getElement() && el.parentNode != this.popup.container)
|
||||
this.detach();
|
||||
}
|
||||
};
|
||||
|
||||
this.mousedownListener = function(e) {
|
||||
|
|
@ -181,7 +159,7 @@ var Autocomplete = function() {
|
|||
return false;
|
||||
|
||||
if (data.completer && data.completer.insertMatch) {
|
||||
data.completer.insertMatch(this.editor, data);
|
||||
data.completer.insertMatch(this.editor);
|
||||
} else {
|
||||
if (this.completions.filterText) {
|
||||
var ranges = this.editor.selection.getAllRanges();
|
||||
|
|
@ -198,7 +176,6 @@ var Autocomplete = function() {
|
|||
this.detach();
|
||||
};
|
||||
|
||||
|
||||
this.commands = {
|
||||
"Up": function(editor) { editor.completer.goTo("up"); },
|
||||
"Down": function(editor) { editor.completer.goTo("down"); },
|
||||
|
|
@ -206,6 +183,7 @@ var Autocomplete = function() {
|
|||
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
|
||||
|
||||
"Esc": function(editor) { editor.completer.detach(); },
|
||||
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
|
||||
"Return": function(editor) { return editor.completer.insertMatch(); },
|
||||
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
|
||||
"Tab": function(editor) {
|
||||
|
|
@ -228,7 +206,6 @@ var Autocomplete = function() {
|
|||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||
|
||||
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
|
||||
this.base.$insertRight = true;
|
||||
|
||||
var matches = [];
|
||||
var total = editor.completers.length;
|
||||
|
|
@ -262,6 +239,7 @@ var Autocomplete = function() {
|
|||
editor.completer = this;
|
||||
}
|
||||
|
||||
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
||||
editor.on("changeSelection", this.changeListener);
|
||||
editor.on("blur", this.blurListener);
|
||||
editor.on("mousedown", this.mousedownListener);
|
||||
|
|
@ -298,7 +276,7 @@ var Autocomplete = function() {
|
|||
|
||||
var prefix = results.prefix;
|
||||
var matches = results && results.matches;
|
||||
|
||||
|
||||
if (!matches || !matches.length)
|
||||
return detachIfFinished();
|
||||
|
||||
|
|
@ -307,10 +285,6 @@ var Autocomplete = function() {
|
|||
return;
|
||||
|
||||
this.completions = new FilteredList(matches);
|
||||
|
||||
if (this.exactMatch)
|
||||
this.completions.exactMatch = true;
|
||||
|
||||
this.completions.setFilter(prefix);
|
||||
var filtered = this.completions.filtered;
|
||||
|
||||
|
|
@ -323,7 +297,7 @@ var Autocomplete = function() {
|
|||
return detachIfFinished();
|
||||
|
||||
// Autoinsert if one result
|
||||
if (this.autoInsert && filtered.length == 1 && results.finished)
|
||||
if (this.autoInsert && filtered.length == 1)
|
||||
return this.insertMatch(filtered[0]);
|
||||
|
||||
this.openPopup(this.editor, prefix, keepPopupPosition);
|
||||
|
|
@ -334,73 +308,6 @@ var Autocomplete = function() {
|
|||
this.editor.$mouseHandler.cancelContextMenu();
|
||||
};
|
||||
|
||||
this.updateDocTooltip = function() {
|
||||
var popup = this.popup;
|
||||
var all = popup.data;
|
||||
var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
|
||||
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);
|
||||
|
||||
Autocomplete.startCommand = {
|
||||
|
|
@ -408,20 +315,19 @@ Autocomplete.startCommand = {
|
|||
exec: function(editor) {
|
||||
if (!editor.completer)
|
||||
editor.completer = new Autocomplete();
|
||||
editor.completer.autoInsert = false;
|
||||
editor.completer.autoInsert =
|
||||
editor.completer.autoSelect = true;
|
||||
editor.completer.showPopup(editor);
|
||||
// prevent ctrl-space opening context menu on firefox on mac
|
||||
// needed for firefox on mac
|
||||
editor.completer.cancelContextMenu();
|
||||
},
|
||||
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
|
||||
};
|
||||
|
||||
var FilteredList = function(array, filterText) {
|
||||
var FilteredList = function(array, filterText, mutateData) {
|
||||
this.all = array;
|
||||
this.filtered = array;
|
||||
this.filterText = filterText || "";
|
||||
this.exactMatch = false;
|
||||
};
|
||||
(function(){
|
||||
this.setFilter = function(str) {
|
||||
|
|
@ -439,7 +345,7 @@ var FilteredList = function(array, filterText) {
|
|||
// make unique
|
||||
var prev = null;
|
||||
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;
|
||||
prev = caption;
|
||||
return true;
|
||||
|
|
@ -458,29 +364,23 @@ var FilteredList = function(array, filterText) {
|
|||
var matchMask = 0;
|
||||
var penalty = 0;
|
||||
var index, distance;
|
||||
|
||||
if (this.exactMatch) {
|
||||
if (needle !== caption.substr(0, needle.length))
|
||||
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
|
||||
for (var j = 0; j < needle.length; j++) {
|
||||
// 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;
|
||||
}else{
|
||||
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
|
||||
for (var j = 0; j < needle.length; j++) {
|
||||
// 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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
item.matchMask = matchMask;
|
||||
item.exactMatch = penalty ? 0 : 1;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var EditSession = require("../edit_session").EditSession;
|
||||
var Renderer = require("../virtual_renderer").VirtualRenderer;
|
||||
var Editor = require("../editor").Editor;
|
||||
var Range = require("../range").Range;
|
||||
|
|
@ -51,7 +52,6 @@ var $singleLineEditor = function(el) {
|
|||
editor.renderer.setHighlightGutterLine(false);
|
||||
|
||||
editor.$mouseHandler.$focusWaitTimout = 0;
|
||||
editor.$highlightTagPending = true;
|
||||
|
||||
return editor;
|
||||
};
|
||||
|
|
@ -103,7 +103,7 @@ var AcePopup = function(parentNode) {
|
|||
popup.session.removeMarker(hoverMarker.id);
|
||||
hoverMarker.id = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
popup.setSelectOnHover(false);
|
||||
popup.on("mousemove", function(e) {
|
||||
if (!lastMouseEvent) {
|
||||
|
|
@ -171,8 +171,8 @@ var AcePopup = function(parentNode) {
|
|||
};
|
||||
|
||||
var bgTokenizer = popup.session.bgTokenizer;
|
||||
bgTokenizer.$tokenizeRow = function(row) {
|
||||
var data = popup.data[row];
|
||||
bgTokenizer.$tokenizeRow = function(i) {
|
||||
var data = popup.data[i];
|
||||
var tokens = [];
|
||||
if (!data)
|
||||
return tokens;
|
||||
|
|
@ -196,12 +196,8 @@ var AcePopup = function(parentNode) {
|
|||
|
||||
if (data.meta) {
|
||||
var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
|
||||
var metaData = data.meta;
|
||||
if (metaData.length + data.caption.length > maxW - 2) {
|
||||
// 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});
|
||||
if (data.meta.length + data.caption.length < maxW - 2)
|
||||
tokens.push({type: "rightAlignedText", value: data.meta});
|
||||
}
|
||||
return tokens;
|
||||
};
|
||||
|
|
@ -210,9 +206,7 @@ var AcePopup = function(parentNode) {
|
|||
|
||||
popup.session.$computeWidth = function() {
|
||||
return this.screenWidth = 0;
|
||||
};
|
||||
|
||||
popup.$blockScrolling = Infinity;
|
||||
}
|
||||
|
||||
// public
|
||||
popup.isOpen = false;
|
||||
|
|
@ -220,8 +214,8 @@ var AcePopup = function(parentNode) {
|
|||
|
||||
popup.data = [];
|
||||
popup.setData = function(list) {
|
||||
popup.setValue(lang.stringRepeat("\n", list.length), -1);
|
||||
popup.data = list || [];
|
||||
popup.setValue(lang.stringRepeat("\n", list.length), -1);
|
||||
popup.setRow(0);
|
||||
};
|
||||
popup.getData = function(row) {
|
||||
|
|
@ -341,4 +335,4 @@ dom.importCssString("\
|
|||
|
||||
exports.AcePopup = AcePopup;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
@ -68,10 +68,11 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
var endLine = -1;
|
||||
var doc = self.doc;
|
||||
|
||||
var startLine = currentLine;
|
||||
while (self.lines[currentLine])
|
||||
currentLine++;
|
||||
|
||||
|
||||
var startLine = currentLine;
|
||||
|
||||
var len = doc.getLength();
|
||||
var processedLines = 0;
|
||||
self.running = false;
|
||||
|
|
@ -171,12 +172,13 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
}
|
||||
|
||||
this.$updateOnChange = function(delta) {
|
||||
var startRow = delta.start.row;
|
||||
var len = delta.end.row - startRow;
|
||||
var range = delta.range;
|
||||
var startRow = range.start.row;
|
||||
var len = range.end.row - startRow;
|
||||
|
||||
if (len === 0) {
|
||||
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.states.splice(startRow, len + 1, null);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -75,49 +75,6 @@ module.exports = {
|
|||
|
||||
forceTokenize(doc)
|
||||
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"]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,44 +2,38 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @class CommandManager
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
**/
|
||||
|
||||
var CommandManager = function(platform, commands) {
|
||||
MultiHashHandler.call(this, commands, platform);
|
||||
HashHandler.call(this, commands, platform);
|
||||
this.byName = this.commands;
|
||||
this.setDefaultHandler("exec", function(e) {
|
||||
return e.command.exec(e.editor, e.args || {});
|
||||
});
|
||||
};
|
||||
|
||||
oop.inherits(CommandManager, MultiHashHandler);
|
||||
oop.inherits(CommandManager, HashHandler);
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.exec = function(command, editor, args) {
|
||||
if (Array.isArray(command)) {
|
||||
for (var i = command.length; i--; ) {
|
||||
if (this.exec(command[i], editor, args)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof command === "string")
|
||||
if (typeof command === 'string')
|
||||
command = this.commands[command];
|
||||
|
||||
if (!command)
|
||||
|
|
@ -49,10 +43,10 @@ oop.inherits(CommandManager, MultiHashHandler);
|
|||
return false;
|
||||
|
||||
var e = {editor: editor, command: command, args: args};
|
||||
e.returnValue = this._emit("exec", e);
|
||||
var retvalue = this._emit("exec", e);
|
||||
this._signal("afterExec", e);
|
||||
|
||||
return e.returnValue === false ? false : true;
|
||||
return retvalue === false ? false : true;
|
||||
};
|
||||
|
||||
this.toggleRecording = function(editor) {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ module.exports = {
|
|||
assert.equal(command, "cm2");
|
||||
|
||||
var command = this.cm.findKeyCommand(0, "return");
|
||||
assert.equal(command + "", ["cm4", "cm3"] + "");
|
||||
assert.equal(command, "cm3");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -97,33 +97,29 @@ exports.commands = [{
|
|||
name: "fold",
|
||||
bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
|
||||
exec: function(editor) { editor.session.toggleFold(false); },
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "center",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "unfold",
|
||||
bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
|
||||
exec: function(editor) { editor.session.toggleFold(true); },
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "center",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "toggleFoldWidget",
|
||||
bindKey: bindKey("F2", "F2"),
|
||||
exec: function(editor) { editor.session.toggleFoldWidget(); },
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "center",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "toggleParentFoldWidget",
|
||||
bindKey: bindKey("Alt-F2", "Alt-F2"),
|
||||
exec: function(editor) { editor.session.toggleFoldWidget(true); },
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "center",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "foldall",
|
||||
bindKey: bindKey(null, "Ctrl-Command-Option-0"),
|
||||
bindKey: bindKey("Ctrl-Alt-0", "Ctrl-Command-Option-0"),
|
||||
exec: function(editor) { editor.session.foldAll(); },
|
||||
scrollIntoView: "center",
|
||||
readOnly: true
|
||||
|
|
@ -419,16 +415,10 @@ exports.commands = [{
|
|||
readOnly: true
|
||||
}, {
|
||||
name: "passKeysToBrowser",
|
||||
bindKey: bindKey(null, null),
|
||||
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
|
||||
|
|
@ -445,12 +435,6 @@ exports.commands = [{
|
|||
},
|
||||
scrollIntoView: "cursor",
|
||||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
name: "paste",
|
||||
exec: function(editor, args) {
|
||||
editor.$handlePaste(args);
|
||||
},
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "removeline",
|
||||
bindKey: bindKey("Ctrl-D", "Command-D"),
|
||||
|
|
|
|||
|
|
@ -69,14 +69,18 @@ exports.iSearchCommands = [{
|
|||
bindKey: {win: "Ctrl-F", mac: "Command-F"},
|
||||
exec: function(iSearch) {
|
||||
iSearch.cancelSearch(true);
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: "searchForward",
|
||||
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
|
||||
exec: function(iSearch, options) {
|
||||
options.useCurrentOrPrevSearch = true;
|
||||
iSearch.next(options);
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: "searchBackward",
|
||||
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
|
||||
|
|
@ -84,30 +88,42 @@ exports.iSearchCommands = [{
|
|||
options.useCurrentOrPrevSearch = true;
|
||||
options.backwards = true;
|
||||
iSearch.next(options);
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: "extendSearchTerm",
|
||||
exec: function(iSearch, string) {
|
||||
iSearch.addString(string);
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: "extendSearchTermSpace",
|
||||
bindKey: "space",
|
||||
exec: function(iSearch) { iSearch.addString(' '); }
|
||||
exec: function(iSearch) { iSearch.addString(' '); },
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: "shrinkSearchTerm",
|
||||
bindKey: "backspace",
|
||||
exec: function(iSearch) {
|
||||
iSearch.removeChar();
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: 'confirmSearch',
|
||||
bindKey: 'return',
|
||||
exec: function(iSearch) { iSearch.deactivate(); }
|
||||
exec: function(iSearch) { iSearch.deactivate(); },
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: 'cancelSearch',
|
||||
bindKey: 'esc|Ctrl-G',
|
||||
exec: function(iSearch) { iSearch.deactivate(true); }
|
||||
exec: function(iSearch) { iSearch.deactivate(true); },
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: 'occurisearch',
|
||||
bindKey: 'Ctrl-O',
|
||||
|
|
@ -115,7 +131,9 @@ exports.iSearchCommands = [{
|
|||
var options = oop.mixin({}, iSearch.$options);
|
||||
iSearch.deactivate();
|
||||
occurStartCommand.exec(iSearch.$editor, options);
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: "yankNextWord",
|
||||
bindKey: "Ctrl-w",
|
||||
|
|
@ -124,7 +142,9 @@ exports.iSearchCommands = [{
|
|||
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
|
||||
string = ed.session.getTextRange(range);
|
||||
iSearch.addString(string);
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: "yankNextChar",
|
||||
bindKey: "Ctrl-Alt-y",
|
||||
|
|
@ -133,35 +153,16 @@ exports.iSearchCommands = [{
|
|||
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
|
||||
string = ed.session.getTextRange(range);
|
||||
iSearch.addString(string);
|
||||
}
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
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;
|
||||
});
|
||||
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); },
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}];
|
||||
|
||||
function IncrementalSearchKeyboardHandler(iSearch) {
|
||||
this.$iSearch = iSearch;
|
||||
|
|
@ -169,7 +170,7 @@ function IncrementalSearchKeyboardHandler(iSearch) {
|
|||
|
||||
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
||||
|
||||
(function() {
|
||||
;(function() {
|
||||
|
||||
this.attach = function(editor) {
|
||||
var iSearch = this.$iSearch;
|
||||
|
|
@ -178,19 +179,15 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
|||
if (!e.command.isIncrementalSearchCommand) return undefined;
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var scrollTop = editor.session.getScrollTop();
|
||||
var result = e.command.exec(iSearch, e.args || {});
|
||||
editor.renderer.scrollCursorIntoView(null, 0.5);
|
||||
editor.renderer.animateScrolling(scrollTop);
|
||||
return result;
|
||||
return e.command.exec(iSearch, e.args || {});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.detach = function(editor) {
|
||||
if (!this.$commandExecHandler) return;
|
||||
editor.commands.removeEventListener('exec', this.$commandExecHandler);
|
||||
delete this.$commandExecHandler;
|
||||
};
|
||||
}
|
||||
|
||||
var handleKeyboard$super = this.handleKeyboard;
|
||||
this.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||
|
|
@ -203,7 +200,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
|||
if (extendCmd) { return {command: extendCmd, args: key}; }
|
||||
}
|
||||
return {command: "null", passEvent: hashId == 0 || hashId == 4};
|
||||
};
|
||||
}
|
||||
|
||||
}).call(IncrementalSearchKeyboardHandler.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,12 +34,10 @@ define(function(require, exports, module) {
|
|||
var lang = require("./lib/lang");
|
||||
var oop = require("./lib/oop");
|
||||
var net = require("./lib/net");
|
||||
var AppConfig = require("./lib/app_config").AppConfig;
|
||||
|
||||
module.exports = exports = new AppConfig();
|
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
|
||||
var global = (function() {
|
||||
return this || typeof window != "undefined" && window;
|
||||
return this;
|
||||
})();
|
||||
|
||||
var options = {
|
||||
|
|
@ -71,6 +69,8 @@ exports.all = function() {
|
|||
};
|
||||
|
||||
// module loading
|
||||
oop.implement(exports, EventEmitter);
|
||||
|
||||
exports.moduleUrl = function(name, component) {
|
||||
if (options.$moduleUrls[name])
|
||||
return options.$moduleUrls[name];
|
||||
|
|
@ -80,8 +80,8 @@ exports.moduleUrl = function(name, component) {
|
|||
|
||||
// todo make this configurable or get rid of '-'
|
||||
var sep = component == "snippets" ? "/" : "-";
|
||||
var base = parts[parts.length - 1];
|
||||
if (component == "worker" && sep == "-") {
|
||||
var base = parts[parts.length - 1];
|
||||
if (sep == "-") {
|
||||
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
|
||||
base = base.replace(re, "");
|
||||
}
|
||||
|
|
@ -142,6 +142,7 @@ exports.loadModule = function(moduleName, onLoad) {
|
|||
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
|
||||
};
|
||||
|
||||
|
||||
// initialization
|
||||
function init(packaged) {
|
||||
options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
|
||||
|
|
@ -199,4 +200,102 @@ function deHyphenate(str) {
|
|||
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]);
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ module.exports = {
|
|||
"test: path resolution" : function() {
|
||||
config.set("packaged", "true");
|
||||
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");
|
||||
url = config.moduleUrl("m/theme", "theme");
|
||||
|
|
@ -117,19 +117,12 @@ module.exports = {
|
|||
assert.equal(o.getOption("initialValue"), 8);
|
||||
o.setOption("initialValue", 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) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
.ace_editor {
|
||||
position: relative;
|
||||
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;
|
||||
font-size: 12px;
|
||||
line-height: normal;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
|
|
@ -15,7 +17,6 @@
|
|||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.ace_content {
|
||||
|
|
@ -23,9 +24,14 @@
|
|||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
cursor: text;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.ace_dragging, .ace_dragging * {
|
||||
cursor: move !important;
|
||||
}
|
||||
|
||||
.ace_dragging .ace_scroller:before{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
|
@ -149,8 +155,8 @@
|
|||
}
|
||||
|
||||
.ace_text-input.ace_composition {
|
||||
background: inherit;
|
||||
color: inherit;
|
||||
background: #f8f8f8;
|
||||
color: #111;
|
||||
z-index: 1000;
|
||||
opacity: 1;
|
||||
text-indent: 0;
|
||||
|
|
@ -160,8 +166,6 @@
|
|||
z-index: 1;
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
/* workaround for chrome bug https://github.com/ajaxorg/ace/issues/2312*/
|
||||
word-wrap: normal;
|
||||
white-space: pre;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
|
@ -207,7 +211,7 @@
|
|||
}
|
||||
|
||||
.ace_overwrite-cursors .ace_cursor {
|
||||
border-left-width: 0;
|
||||
border-left-width: 0px;
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +220,10 @@
|
|||
}
|
||||
|
||||
.ace_smooth-blinking .ace_cursor {
|
||||
-moz-transition: opacity 0.18s;
|
||||
-webkit-transition: opacity 0.18s;
|
||||
-o-transition: opacity 0.18s;
|
||||
-ms-transition: opacity 0.18s;
|
||||
transition: opacity 0.18s;
|
||||
}
|
||||
|
||||
|
|
@ -270,6 +277,8 @@
|
|||
color: transparent;
|
||||
|
||||
border: 1px solid black;
|
||||
-moz-border-radius: 2px;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
|
||||
cursor: pointer;
|
||||
|
|
@ -293,6 +302,7 @@
|
|||
border-radius: 1px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
|
||||
color: black;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
padding: 3px 4px;
|
||||
position: fixed;
|
||||
|
|
@ -349,12 +359,16 @@
|
|||
.ace_fold-widget:hover {
|
||||
border: 1px solid rgba(0, 0, 0, 0.3);
|
||||
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);
|
||||
}
|
||||
|
||||
.ace_fold-widget:active {
|
||||
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||
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);
|
||||
}
|
||||
/**
|
||||
|
|
@ -374,6 +388,8 @@
|
|||
background-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
.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);
|
||||
}
|
||||
|
||||
|
|
@ -383,13 +399,19 @@
|
|||
}
|
||||
|
||||
.ace_fade-fold-widgets .ace_fold-widget {
|
||||
-moz-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;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.ace_fade-fold-widgets:hover .ace_fold-widget {
|
||||
-moz-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;
|
||||
opacity:1;
|
||||
}
|
||||
|
|
@ -422,30 +444,3 @@
|
|||
position: absolute;
|
||||
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;}
|
||||
|
|
|
|||
|
|
@ -32,36 +32,36 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var applyDelta = require("./apply_delta").applyDelta;
|
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
var Range = require("./range").Range;
|
||||
var Anchor = require("./anchor").Anchor;
|
||||
|
||||
/**
|
||||
* Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s.
|
||||
*
|
||||
* At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
|
||||
*
|
||||
* @class Document
|
||||
**/
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
|
||||
* @param {String | Array} text The starting text
|
||||
* @constructor
|
||||
**/
|
||||
|
||||
var Document = function(textOrLines) {
|
||||
this.$lines = [""];
|
||||
var Document = function(text) {
|
||||
this.$lines = [];
|
||||
|
||||
// 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.
|
||||
if (textOrLines.length === 0) {
|
||||
if (text.length === 0) {
|
||||
this.$lines = [""];
|
||||
} else if (Array.isArray(textOrLines)) {
|
||||
this.insertMergedLines({row: 0, column: 0}, textOrLines);
|
||||
} else if (Array.isArray(text)) {
|
||||
this._insertLines(0, text);
|
||||
} 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
|
||||
**/
|
||||
this.setValue = function(text) {
|
||||
var len = this.getLength() - 1;
|
||||
this.remove(new Range(0, 0, len, this.getLine(len).length));
|
||||
this.insert({row: 0, column: 0}, text);
|
||||
var len = this.getLength();
|
||||
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
|
||||
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
|
||||
* @param {String} text The text to work with
|
||||
|
|
@ -107,15 +107,14 @@ var Document = function(textOrLines) {
|
|||
**/
|
||||
|
||||
// check for IE split bug
|
||||
if ("aaa".split(/a/).length === 0) {
|
||||
if ("aaa".split(/a/).length === 0)
|
||||
this.$split = function(text) {
|
||||
return text.replace(/\r\n|\r/g, "\n").split("\n");
|
||||
};
|
||||
} else {
|
||||
else
|
||||
this.$split = function(text) {
|
||||
return text.split(/\r\n|\r|\n/);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
this.$detectNewLine = function(text) {
|
||||
|
|
@ -208,49 +207,32 @@ var Document = function(textOrLines) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Returns all the text within `range` as a single string.
|
||||
* @param {Range} range The range to work with.
|
||||
* [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
|
||||
* @param {Range} range The range to work with
|
||||
*
|
||||
* @returns {String}
|
||||
**/
|
||||
this.getTextRange = function(range) {
|
||||
return this.getLinesForRange(range).join(this.getNewLineCharacter());
|
||||
};
|
||||
|
||||
/**
|
||||
* 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);
|
||||
if (range.start.row == range.end.row) {
|
||||
return this.getLine(range.start.row)
|
||||
.substring(range.start.column, 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.insertLines = function(row, lines) {
|
||||
console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
|
||||
return this.insertFullLines(row, lines);
|
||||
};
|
||||
this.removeLines = function(firstRow, lastRow) {
|
||||
console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
|
||||
return this.removeFullLines(firstRow, lastRow);
|
||||
};
|
||||
this.insertNewLine = function(position) {
|
||||
console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
|
||||
return this.insertMergedLines(position, ["", ""]);
|
||||
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 if (position.row < 0)
|
||||
position.row = 0;
|
||||
return position;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -261,160 +243,159 @@ var Document = function(textOrLines) {
|
|||
*
|
||||
**/
|
||||
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)
|
||||
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.
|
||||
*
|
||||
* This differs from the `insert` method in two ways:
|
||||
* 1. This does NOT handle newline characters (single-line text only).
|
||||
* 2. This is faster than the `insert` method for single-line text insertions.
|
||||
*
|
||||
* Fires whenever the document changes.
|
||||
*
|
||||
* Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available:
|
||||
*
|
||||
* * `"insertLines"` (emitted by [[Document.insertLines]])
|
||||
* * `range`: the [[Range]] of the change within the document
|
||||
* * `lines`: the lines in the document that are changing
|
||||
* * `"insertText"` (emitted by [[Document.insertNewLine]])
|
||||
* * `range`: the [[Range]] of the change within the document
|
||||
* * `text`: the text that's being added
|
||||
* * `"removeLines"` (emitted by [[Document.insertLines]])
|
||||
* * `range`: the [[Range]] of the change within the document
|
||||
* * `lines`: the lines in the document that were removed
|
||||
* * `nl`: the new line character (as defined by [[Document.getNewLineCharacter]])
|
||||
* * `"removeText"` (emitted by [[Document.removeInLine]] and [[Document.removeNewLine]])
|
||||
* * `range`: the [[Range]] of the change within the document
|
||||
* * `text`: the text that's being removed
|
||||
*
|
||||
* @event change
|
||||
* @param {Object} e Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties.
|
||||
*
|
||||
**/
|
||||
/**
|
||||
* Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
|
||||
* @param {Number} row The index of the row to insert at
|
||||
* @param {Array} lines An array of strings
|
||||
* @returns {Object} Contains the final row and column, like this:
|
||||
* ```
|
||||
* {row: endRow, column: 0}
|
||||
* ```
|
||||
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
|
||||
* ```
|
||||
* {row: row, column: 0}
|
||||
* ```
|
||||
*
|
||||
**/
|
||||
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
|
||||
while (lines.length > 0xF000) {
|
||||
var end = this._insertLines(row, lines.slice(0, 0xF000));
|
||||
lines = lines.slice(0xF000);
|
||||
row = end.row;
|
||||
}
|
||||
|
||||
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._signal("change", { data: delta });
|
||||
return 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._signal("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 {String} text A chunk of text
|
||||
* @returns {Object} Returns an object containing the final row and column, like this:
|
||||
* ```
|
||||
* {row: endRow, column: 0}
|
||||
* ```
|
||||
*
|
||||
**/
|
||||
this.insertInLine = function(position, text) {
|
||||
var start = this.clippedPos(position.row, position.column);
|
||||
var end = this.pos(position.row, position.column + text.length);
|
||||
|
||||
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;
|
||||
};
|
||||
if (text.length == 0)
|
||||
return position;
|
||||
|
||||
/**
|
||||
* Fires whenever the document changes.
|
||||
*
|
||||
* Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available:
|
||||
*
|
||||
* * `"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);
|
||||
};
|
||||
var line = this.$lines[position.row] || "";
|
||||
|
||||
this.$lines[position.row] = line.substring(0, position.column) + text
|
||||
+ line.substring(position.column);
|
||||
|
||||
/**
|
||||
* 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 = {
|
||||
row: start.row + lines.length - 1,
|
||||
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
|
||||
row : position.row,
|
||||
column : position.column + text.length
|
||||
};
|
||||
|
||||
this.applyDelta({
|
||||
start: start,
|
||||
end: end,
|
||||
action: "insert",
|
||||
lines: lines
|
||||
});
|
||||
|
||||
return this.clonePos(end);
|
||||
|
||||
var delta = {
|
||||
action: "insertText",
|
||||
range: Range.fromPoints(position, end),
|
||||
text: text
|
||||
};
|
||||
this._signal("change", { data: delta });
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -424,90 +405,113 @@ var Document = function(textOrLines) {
|
|||
*
|
||||
**/
|
||||
this.remove = function(range) {
|
||||
var start = this.clippedPos(range.start.row, range.start.column);
|
||||
var end = this.clippedPos(range.end.row, range.end.column);
|
||||
this.applyDelta({
|
||||
start: start,
|
||||
end: end,
|
||||
action: "remove",
|
||||
lines: this.getLinesForRange({start: start, end: end})
|
||||
});
|
||||
return this.clonePos(start);
|
||||
if (!(range instanceof Range))
|
||||
range = Range.fromPoints(range.start, range.end);
|
||||
// clip to document
|
||||
range.start = this.$clipPosition(range.start);
|
||||
range.end = this.$clipPosition(range.end);
|
||||
|
||||
if (range.isEmpty())
|
||||
return range.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.
|
||||
* @param {Number} row The row to remove from
|
||||
* @param {Number} startColumn The column to start removing at
|
||||
* @param {Number} endColumn The column to stop removing at
|
||||
* @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
|
||||
*
|
||||
**/
|
||||
* Removes the specified columns from the `row`. This method also triggers the `'change'` event.
|
||||
* @param {Number} row The row to remove from
|
||||
* @param {Number} startColumn The column to start removing at
|
||||
* @param {Number} endColumn The column to stop removing at
|
||||
* @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
|
||||
*
|
||||
**/
|
||||
this.removeInLine = function(row, startColumn, endColumn) {
|
||||
var start = this.clippedPos(row, startColumn);
|
||||
var end = this.clippedPos(row, endColumn);
|
||||
|
||||
this.applyDelta({
|
||||
start: start,
|
||||
end: end,
|
||||
action: "remove",
|
||||
lines: this.getLinesForRange({start: start, end: end})
|
||||
}, true);
|
||||
|
||||
return this.clonePos(start);
|
||||
if (startColumn == endColumn)
|
||||
return;
|
||||
|
||||
var range = new Range(row, startColumn, row, endColumn);
|
||||
var line = this.getLine(row);
|
||||
var removed = line.substring(startColumn, endColumn);
|
||||
var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
|
||||
this.$lines.splice(row, 1, newLine);
|
||||
|
||||
var delta = {
|
||||
action: "removeText",
|
||||
range: range,
|
||||
text: removed
|
||||
};
|
||||
this._signal("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} lastRow The last row to be removed
|
||||
* @returns {[String]} Returns all the removed lines.
|
||||
*
|
||||
**/
|
||||
this.removeFullLines = function(firstRow, lastRow) {
|
||||
// Clip to document.
|
||||
firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
|
||||
lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
|
||||
|
||||
// Calculate deletion range.
|
||||
// Delete the ending new line unless we're at the end of the document.
|
||||
// If we're at the end of the document, delete the starting new line.
|
||||
var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
|
||||
var deleteLastNewLine = lastRow < this.getLength() - 1;
|
||||
var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
|
||||
var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
|
||||
var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
|
||||
var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
|
||||
var range = new Range(startRow, startCol, endRow, endCol);
|
||||
|
||||
// Store delelted lines with bounding newlines ommitted (maintains previous behavior).
|
||||
var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
|
||||
|
||||
this.applyDelta({
|
||||
start: range.start,
|
||||
end: range.end,
|
||||
action: "remove",
|
||||
lines: this.getLinesForRange(range)
|
||||
});
|
||||
|
||||
// Return the deleted lines.
|
||||
return deletedLines;
|
||||
this.removeLines = function(firstRow, lastRow) {
|
||||
if (firstRow < 0 || lastRow >= this.getLength())
|
||||
return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
|
||||
return this._removeLines(firstRow, lastRow);
|
||||
};
|
||||
|
||||
this._removeLines = function(firstRow, lastRow) {
|
||||
var range = new Range(firstRow, 0, lastRow + 1, 0);
|
||||
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
|
||||
|
||||
var delta = {
|
||||
action: "removeLines",
|
||||
range: range,
|
||||
nl: this.getNewLineCharacter(),
|
||||
lines: removed
|
||||
};
|
||||
this._signal("change", { data: delta });
|
||||
return removed;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
**/
|
||||
this.removeNewLine = function(row) {
|
||||
if (row < this.getLength() - 1 && row >= 0) {
|
||||
this.applyDelta({
|
||||
start: this.pos(row, this.getLine(row).length),
|
||||
end: this.pos(row + 1, 0),
|
||||
action: "remove",
|
||||
lines: ["", ""]
|
||||
});
|
||||
}
|
||||
var firstLine = this.getLine(row);
|
||||
var secondLine = this.getLine(row+1);
|
||||
|
||||
var range = new Range(row, firstLine.length, row+1, 0);
|
||||
var line = firstLine + secondLine;
|
||||
|
||||
this.$lines.splice(row, 2, line);
|
||||
|
||||
var delta = {
|
||||
action: "removeText",
|
||||
range: range,
|
||||
text: this.getNewLineCharacter()
|
||||
};
|
||||
this._signal("change", { data: delta });
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -521,9 +525,9 @@ var Document = function(textOrLines) {
|
|||
*
|
||||
**/
|
||||
this.replace = function(range, text) {
|
||||
if (!range instanceof Range)
|
||||
if (!(range instanceof Range))
|
||||
range = Range.fromPoints(range.start, range.end);
|
||||
if (text.length === 0 && range.isEmpty())
|
||||
if (text.length == 0 && range.isEmpty())
|
||||
return range.start;
|
||||
|
||||
// Shortcut: If the text we want to insert is the same as it is already
|
||||
|
|
@ -532,106 +536,55 @@ var Document = function(textOrLines) {
|
|||
return range.end;
|
||||
|
||||
this.remove(range);
|
||||
var end;
|
||||
if (text) {
|
||||
end = this.insert(range.start, text);
|
||||
var end = this.insert(range.start, text);
|
||||
}
|
||||
else {
|
||||
end = range.start;
|
||||
}
|
||||
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies all changes in `deltas` to the document.
|
||||
* @param {Array} deltas An array of delta objects (can include "insert" and "remove" actions)
|
||||
* Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
|
||||
**/
|
||||
this.applyDeltas = function(deltas) {
|
||||
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.
|
||||
* @param {Array} deltas An array of delta objects (can include "insert" and "remove" actions)
|
||||
* Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
|
||||
**/
|
||||
this.revertDeltas = function(deltas) {
|
||||
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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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");
|
||||
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
|
||||
|
|
@ -63,9 +63,9 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
@ -80,9 +80,9 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
@ -97,9 +97,9 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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"));
|
||||
},
|
||||
|
||||
|
|
@ -107,9 +107,9 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
@ -124,7 +124,7 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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");
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n"));
|
||||
|
|
@ -141,9 +141,9 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
@ -158,7 +158,7 @@ module.exports = {
|
|||
var doc = new Document(["12", "34"]);
|
||||
|
||||
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");
|
||||
assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n"));
|
||||
|
|
@ -175,7 +175,7 @@ module.exports = {
|
|||
var doc = new Document(["1234", "5678"]);
|
||||
|
||||
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));
|
||||
assert.equal(doc.getValue(), ["14", "5678"].join("\n"));
|
||||
|
|
@ -192,7 +192,7 @@ module.exports = {
|
|||
var doc = new Document(["1234", "5678"]);
|
||||
|
||||
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));
|
||||
assert.equal(doc.getValue(), ["12345678"].join("\n"));
|
||||
|
|
@ -209,7 +209,7 @@ module.exports = {
|
|||
var doc = new Document(["1234", "5678", "abcd"]);
|
||||
|
||||
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));
|
||||
assert.equal(doc.getValue(), ["12cd"].join("\n"));
|
||||
|
|
@ -226,7 +226,7 @@ module.exports = {
|
|||
var doc = new Document(["1234", "5678", "abcd"]);
|
||||
|
||||
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));
|
||||
assert.equal(doc.getValue(), ["1234", ""].join("\n"));
|
||||
|
|
@ -235,7 +235,7 @@ module.exports = {
|
|||
"test: remove lines should return the removed lines" : function() {
|
||||
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"));
|
||||
},
|
||||
|
||||
|
|
@ -296,35 +296,6 @@ module.exports = {
|
|||
"test: empty document has to contain one line": function() {
|
||||
var doc = new Document("");
|
||||
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");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ var EditSession = function(text, mode) {
|
|||
this.$foldData = [];
|
||||
this.$foldData.toString = function() {
|
||||
return this.join("\n");
|
||||
};
|
||||
}
|
||||
this.on("changeFold", this.onChangeFold.bind(this));
|
||||
this.$onChange = this.onChange.bind(this);
|
||||
|
||||
|
|
@ -249,12 +249,13 @@ var EditSession = function(text, mode) {
|
|||
this.$resetRowCache(fold.start.row);
|
||||
};
|
||||
|
||||
this.onChange = function(delta) {
|
||||
this.onChange = function(e) {
|
||||
var delta = e.data;
|
||||
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) {
|
||||
this.$deltasDoc.push(delta);
|
||||
if (removedFolds && removedFolds.length != 0) {
|
||||
|
|
@ -267,14 +268,16 @@ var EditSession = function(text, mode) {
|
|||
this.$informUndoManager.schedule();
|
||||
}
|
||||
|
||||
this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
|
||||
this._signal("change", delta);
|
||||
this.bgTokenizer.$updateOnChange(delta);
|
||||
this._signal("change", e);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the session text.
|
||||
* @param {String} text The new text to place
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.setValue = function(text) {
|
||||
this.doc.setValue(text);
|
||||
|
|
@ -678,10 +681,10 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @returns {Object}
|
||||
* @returns {Array}
|
||||
**/
|
||||
this.getMarkers = function(inFront) {
|
||||
return inFront ? this.$frontMarkers : this.$backMarkers;
|
||||
|
|
@ -892,17 +895,17 @@ var EditSession = function(text, mode) {
|
|||
config.loadModule(["mode", path], function(m) {
|
||||
if (this.$modeId !== path)
|
||||
return cb && cb();
|
||||
if (this.$modes[path] && !options) {
|
||||
this.$onChangeMode(this.$modes[path]);
|
||||
} else if (m && m.Mode) {
|
||||
if (this.$modes[path] && !options)
|
||||
return this.$onChangeMode(this.$modes[path]);
|
||||
if (m && m.Mode) {
|
||||
m = new m.Mode(options);
|
||||
if (!options) {
|
||||
this.$modes[path] = m;
|
||||
m.$id = path;
|
||||
}
|
||||
this.$onChangeMode(m);
|
||||
cb && cb();
|
||||
}
|
||||
cb && cb();
|
||||
}.bind(this));
|
||||
|
||||
// set mode to text until loading is finished
|
||||
|
|
@ -947,9 +950,6 @@ var EditSession = function(text, mode) {
|
|||
|
||||
|
||||
if (!$isPlaceholder) {
|
||||
// experimental method, used by c9 findiniles
|
||||
if (mode.attachToSession)
|
||||
mode.attachToSession(this);
|
||||
this.$options.wrapMethod.set.call(this, this.$wrapMethod);
|
||||
this.$setFolding(mode.foldingRules);
|
||||
this.bgTokenizer.start(0);
|
||||
|
|
@ -957,20 +957,26 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
this.$stopWorker = function() {
|
||||
if (this.$worker) {
|
||||
if (this.$worker)
|
||||
this.$worker.terminate();
|
||||
this.$worker = null;
|
||||
}
|
||||
|
||||
this.$worker = null;
|
||||
};
|
||||
|
||||
this.$startWorker = function() {
|
||||
try {
|
||||
this.$worker = this.$mode.createWorker(this);
|
||||
} catch (e) {
|
||||
config.warn("Could not load worker", e);
|
||||
this.$worker = null;
|
||||
if (typeof Worker !== "undefined" && !require.noWorker) {
|
||||
try {
|
||||
this.$worker = this.$mode.createWorker(this);
|
||||
} catch (e) {
|
||||
console.log("Could not load worker");
|
||||
console.log(e);
|
||||
this.$worker = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
this.$worker = null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1145,19 +1151,6 @@ var EditSession = function(text, mode) {
|
|||
this.remove = function(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.
|
||||
|
|
@ -1234,36 +1227,39 @@ var EditSession = function(text, mode) {
|
|||
|
||||
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
|
||||
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 range, point;
|
||||
var lastDeltaIsInsert = false;
|
||||
if (isInsert(delta)) {
|
||||
range = Range.fromPoints(delta.start, delta.end);
|
||||
range = Range.fromPoints(delta.range.start, delta.range.end);
|
||||
lastDeltaIsInsert = true;
|
||||
} else {
|
||||
range = Range.fromPoints(delta.start, delta.start);
|
||||
range = Range.fromPoints(delta.range.start, delta.range.start);
|
||||
lastDeltaIsInsert = false;
|
||||
}
|
||||
|
||||
for (var i = 1; i < deltas.length; i++) {
|
||||
delta = deltas[i];
|
||||
if (isInsert(delta)) {
|
||||
point = delta.start;
|
||||
point = delta.range.start;
|
||||
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) {
|
||||
range.setEnd(point);
|
||||
range.setEnd(delta.range.end);
|
||||
}
|
||||
lastDeltaIsInsert = true;
|
||||
} else {
|
||||
point = delta.start;
|
||||
point = delta.range.start;
|
||||
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;
|
||||
}
|
||||
|
|
@ -1377,7 +1373,7 @@ var EditSession = function(text, mode) {
|
|||
this.indentRows = function(startRow, endRow, indentString) {
|
||||
indentString = indentString.replace(/\t/g, this.getTabString());
|
||||
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;
|
||||
return x;
|
||||
});
|
||||
|
||||
|
||||
var lines = dir == 0
|
||||
? this.doc.getLines(firstRow, lastRow)
|
||||
: this.doc.removeFullLines(firstRow, lastRow);
|
||||
this.doc.insertFullLines(firstRow+diff, lines);
|
||||
: this.doc.removeLines(firstRow, lastRow);
|
||||
this.doc.insertLines(firstRow+diff, lines);
|
||||
folds.length && this.addFolds(folds);
|
||||
return diff;
|
||||
};
|
||||
|
|
@ -1448,6 +1444,8 @@ var EditSession = function(text, mode) {
|
|||
* @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.
|
||||
*
|
||||
* @related Document.insertLines
|
||||
*
|
||||
**/
|
||||
this.moveLinesUp = function(firstRow, lastRow) {
|
||||
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} 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.
|
||||
*
|
||||
* @related Document.insertLines
|
||||
**/
|
||||
this.moveLinesDown = function(firstRow, lastRow) {
|
||||
return this.$moveLines(firstRow, lastRow, 1);
|
||||
|
|
@ -1585,11 +1585,13 @@ var EditSession = function(text, mode) {
|
|||
**/
|
||||
this.setWrapLimitRange = function(min, 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 will force a recalculation of the wrap limit
|
||||
if (this.$useWrapMode)
|
||||
this._signal("changeWrapMode");
|
||||
this._signal("changeWrapMode");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1601,7 +1603,7 @@ var EditSession = function(text, mode) {
|
|||
* @private
|
||||
**/
|
||||
this.adjustWrapLimit = function(desiredLimit, $printMargin) {
|
||||
var limits = this.$wrapLimitRange;
|
||||
var limits = this.$wrapLimitRange
|
||||
if (limits.max < 0)
|
||||
limits = {min: $printMargin, max: $printMargin};
|
||||
var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
|
||||
|
|
@ -1661,23 +1663,34 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
};
|
||||
|
||||
this.$updateInternalDataOnChange = function(delta) {
|
||||
this.$updateInternalDataOnChange = function(e) {
|
||||
var useWrapMode = this.$useWrapMode;
|
||||
var action = delta.action;
|
||||
var start = delta.start;
|
||||
var end = delta.end;
|
||||
var firstRow = start.row;
|
||||
var lastRow = end.row;
|
||||
var len = lastRow - firstRow;
|
||||
var len;
|
||||
var action = e.data.action;
|
||||
var firstRow = e.data.range.start.row;
|
||||
var lastRow = e.data.range.end.row;
|
||||
var start = e.data.range.start;
|
||||
var end = e.data.range.end;
|
||||
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;
|
||||
if (len != 0) {
|
||||
if (action === "remove") {
|
||||
if (action.indexOf("remove") != -1) {
|
||||
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
|
||||
|
||||
var foldLines = this.$foldData;
|
||||
removedFolds = this.getFoldsInRange(delta);
|
||||
removedFolds = this.getFoldsInRange(e.data.range);
|
||||
this.removeFolds(removedFolds);
|
||||
|
||||
var foldLine = this.getFoldLine(end.row);
|
||||
|
|
@ -1714,14 +1727,13 @@ var EditSession = function(text, mode) {
|
|||
var foldLine = this.getFoldLine(firstRow);
|
||||
var idx = 0;
|
||||
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.
|
||||
if (cmp == 0) {
|
||||
foldLine = foldLine.split(start.row, start.column);
|
||||
if (foldLine) {
|
||||
foldLine.shiftRow(len);
|
||||
foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
|
||||
}
|
||||
foldLine.shiftRow(len);
|
||||
foldLine.addRemoveChars(
|
||||
lastRow, 0, end.column - start.column);
|
||||
} else
|
||||
// Infront of the foldLine but same row. Need to shift column.
|
||||
if (cmp == -1) {
|
||||
|
|
@ -1742,10 +1754,10 @@ var EditSession = function(text, mode) {
|
|||
} else {
|
||||
// Realign folds. E.g. if you add some new chars before a fold, the
|
||||
// fold should "move" to the right.
|
||||
len = Math.abs(delta.start.column - delta.end.column);
|
||||
if (action === "remove") {
|
||||
len = Math.abs(e.data.range.start.column - e.data.range.end.column);
|
||||
if (action.indexOf("remove") != -1) {
|
||||
// Get all the folds in the change range and remove them.
|
||||
removedFolds = this.getFoldsInRange(delta);
|
||||
removedFolds = this.getFoldsInRange(e.data.range);
|
||||
this.removeFolds(removedFolds);
|
||||
|
||||
len = -len;
|
||||
|
|
@ -1829,7 +1841,7 @@ var EditSession = function(text, mode) {
|
|||
TAB_SPACE = 12;
|
||||
|
||||
|
||||
this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
|
||||
this.$computeWrapSplits = function(tokens, wrapLimit) {
|
||||
if (tokens.length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -1840,31 +1852,6 @@ var EditSession = function(text, mode) {
|
|||
|
||||
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) {
|
||||
var displayed = tokens.slice(lastSplit, screenPos);
|
||||
|
||||
|
|
@ -1881,18 +1868,14 @@ var EditSession = function(text, mode) {
|
|||
len -= 1;
|
||||
});
|
||||
|
||||
if (!splits.length) {
|
||||
indent = getWrapIndent();
|
||||
splits.indent = indent;
|
||||
}
|
||||
lastDocSplit += len;
|
||||
splits.push(lastDocSplit);
|
||||
lastSplit = screenPos;
|
||||
}
|
||||
var indent = 0;
|
||||
while (displayLength - lastSplit > wrapLimit - indent) {
|
||||
|
||||
while (displayLength - lastSplit > wrapLimit) {
|
||||
// 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
|
||||
// a split is simple.
|
||||
|
|
@ -1952,7 +1935,7 @@ var EditSession = function(text, mode) {
|
|||
|
||||
// === ELSE ===
|
||||
// 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) {
|
||||
split --;
|
||||
}
|
||||
|
|
@ -1978,9 +1961,7 @@ var EditSession = function(text, mode) {
|
|||
split = lastSplit + wrapLimit;
|
||||
// The split is inside of a CHAR or CHAR_EXT token and no space
|
||||
// around -> force a split.
|
||||
if (tokens[split] == CHAR_EXT)
|
||||
split--;
|
||||
addSplit(split - indent);
|
||||
addSplit(split);
|
||||
}
|
||||
return splits;
|
||||
};
|
||||
|
|
@ -2087,16 +2068,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.
|
||||
* @param {Number} screenRow The screen row to check
|
||||
|
|
@ -2229,26 +2200,25 @@ var EditSession = function(text, mode) {
|
|||
return {
|
||||
row: maxRow,
|
||||
column: this.getLine(maxRow).length
|
||||
};
|
||||
}
|
||||
} else {
|
||||
line = this.getLine(docRow);
|
||||
foldLine = null;
|
||||
}
|
||||
var wrapIndent = 0;
|
||||
|
||||
if (this.$useWrapMode) {
|
||||
var splits = this.$wrapData[docRow];
|
||||
if (splits) {
|
||||
var splitIndex = Math.floor(screenRow - row);
|
||||
column = splits[splitIndex];
|
||||
if(splitIndex > 0 && splits.length) {
|
||||
wrapIndent = splits.indent;
|
||||
docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
|
||||
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
|
||||
// position returned is not associated to the next row on the screen.
|
||||
|
|
@ -2340,7 +2310,6 @@ var EditSession = function(text, mode) {
|
|||
textLine = this.getLine(docRow).substring(0, docColumn);
|
||||
foldStartRow = docRow;
|
||||
}
|
||||
var wrapIndent = 0;
|
||||
// Clamp textLine if in wrapMode.
|
||||
if (this.$useWrapMode) {
|
||||
var wrapRow = this.$wrapData[foldStartRow];
|
||||
|
|
@ -2353,13 +2322,12 @@ var EditSession = function(text, mode) {
|
|||
textLine = textLine.substring(
|
||||
wrapRow[screenRowOffset - 1] || 0, textLine.length
|
||||
);
|
||||
wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
row: screenRow,
|
||||
column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
|
||||
column: this.$getStringScreenWidth(textLine)[0]
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -2432,15 +2400,7 @@ var EditSession = function(text, mode) {
|
|||
*/
|
||||
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
|
||||
|
|
@ -2501,7 +2461,6 @@ config.defineOptions(EditSession.prototype, "session", {
|
|||
|
||||
if (this.$wrap == value)
|
||||
return;
|
||||
this.$wrap = value;
|
||||
if (!value) {
|
||||
this.setUseWrapMode(false);
|
||||
} else {
|
||||
|
|
@ -2509,6 +2468,7 @@ config.defineOptions(EditSession.prototype, "session", {
|
|||
this.setWrapLimitRange(col, col);
|
||||
this.setUseWrapMode(true);
|
||||
}
|
||||
this.$wrap = value;
|
||||
},
|
||||
get: function() {
|
||||
if (this.getUseWrapMode()) {
|
||||
|
|
@ -2539,7 +2499,6 @@ config.defineOptions(EditSession.prototype, "session", {
|
|||
},
|
||||
initialValue: "auto"
|
||||
},
|
||||
indentedSoftWrap: { initialValue: true },
|
||||
firstLineNumber: {
|
||||
set: function() {this._signal("changeBreakpoint");},
|
||||
initialValue: 1
|
||||
|
|
|
|||
|
|
@ -117,7 +117,6 @@ function BracketMatch() {
|
|||
typeRe = new RegExp(
|
||||
"(\\.?" +
|
||||
token.type.replace(".", "\\.").replace("rparen", ".paren")
|
||||
.replace(/\b(?:end)\b/, "(?:start|begin|end)")
|
||||
+ ")+"
|
||||
);
|
||||
}
|
||||
|
|
@ -174,7 +173,6 @@ function BracketMatch() {
|
|||
typeRe = new RegExp(
|
||||
"(\\.?" +
|
||||
token.type.replace(".", "\\.").replace("lparen", ".paren")
|
||||
.replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
|
||||
+ ")+"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ function FoldLine(foldData, folds) {
|
|||
folds = this.folds = [ folds ];
|
||||
}
|
||||
|
||||
var last = folds[folds.length - 1];
|
||||
var last = folds[folds.length - 1]
|
||||
this.range = new Range(folds[0].start.row, folds[0].start.column,
|
||||
last.end.row, last.end.column);
|
||||
this.start = this.range.start;
|
||||
|
|
@ -66,7 +66,7 @@ function FoldLine(foldData, folds) {
|
|||
fold.start.row += shift;
|
||||
fold.end.row += shift;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.addFold = function(fold) {
|
||||
if (fold.sameRow) {
|
||||
|
|
@ -96,17 +96,17 @@ function FoldLine(foldData, folds) {
|
|||
throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
|
||||
}
|
||||
fold.foldLine = this;
|
||||
};
|
||||
}
|
||||
|
||||
this.containsRow = function(row) {
|
||||
return row >= this.start.row && row <= this.end.row;
|
||||
};
|
||||
}
|
||||
|
||||
this.walk = function(callback, endRow, endColumn) {
|
||||
var lastEnd = 0,
|
||||
folds = this.folds,
|
||||
fold,
|
||||
cmp, stop, isNewRow = true;
|
||||
comp, stop, isNewRow = true;
|
||||
|
||||
if (endRow == null) {
|
||||
endRow = this.end.row;
|
||||
|
|
@ -116,9 +116,9 @@ function FoldLine(foldData, folds) {
|
|||
for (var i = 0; i < folds.length; i++) {
|
||||
fold = folds[i];
|
||||
|
||||
cmp = fold.range.compareStart(endRow, endColumn);
|
||||
comp = fold.range.compareStart(endRow, endColumn);
|
||||
// This fold is after the endRow/Column.
|
||||
if (cmp == -1) {
|
||||
if (comp == -1) {
|
||||
callback(null, endRow, endColumn, lastEnd, isNewRow);
|
||||
return;
|
||||
}
|
||||
|
|
@ -127,8 +127,8 @@ function FoldLine(foldData, folds) {
|
|||
stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
|
||||
|
||||
// If the user requested to stop the walk or endRow/endColumn is
|
||||
// inside of this fold (cmp == 0), then end here.
|
||||
if (stop || cmp === 0) {
|
||||
// inside of this fold (comp == 0), then end here.
|
||||
if (stop || comp == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ function FoldLine(foldData, folds) {
|
|||
lastEnd = fold.end.column;
|
||||
}
|
||||
callback(null, endRow, endColumn, lastEnd, isNewRow);
|
||||
};
|
||||
}
|
||||
|
||||
this.getNextFoldTo = function(row, column) {
|
||||
var fold, cmp;
|
||||
|
|
@ -150,15 +150,15 @@ function FoldLine(foldData, folds) {
|
|||
fold: fold,
|
||||
kind: "after"
|
||||
};
|
||||
} else if (cmp === 0) {
|
||||
} else if (cmp == 0) {
|
||||
return {
|
||||
fold: fold,
|
||||
kind: "inside"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
this.addRemoveChars = function(row, column, len) {
|
||||
var ret = this.getNextFoldTo(row, column),
|
||||
|
|
@ -175,7 +175,7 @@ function FoldLine(foldData, folds) {
|
|||
} else if (fold.start.row == row) {
|
||||
folds = this.folds;
|
||||
var i = folds.indexOf(fold);
|
||||
if (i === 0) {
|
||||
if (i == 0) {
|
||||
this.start.column += len;
|
||||
}
|
||||
for (i; i < folds.length; i++) {
|
||||
|
|
@ -189,18 +189,16 @@ function FoldLine(foldData, folds) {
|
|||
this.end.column += len;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.split = function(row, column) {
|
||||
var pos = this.getNextFoldTo(row, column);
|
||||
|
||||
if (!pos || pos.kind == "inside")
|
||||
return null;
|
||||
|
||||
var fold = pos.fold;
|
||||
var fold = this.getNextFoldTo(row, column).fold;
|
||||
var folds = this.folds;
|
||||
var foldData = this.foldData;
|
||||
|
||||
|
||||
if (!fold)
|
||||
return null;
|
||||
|
||||
var i = folds.indexOf(fold);
|
||||
var foldBefore = folds[i - 1];
|
||||
this.end.row = foldBefore.end.row;
|
||||
|
|
@ -213,7 +211,7 @@ function FoldLine(foldData, folds) {
|
|||
var newFoldLine = new FoldLine(foldData, folds);
|
||||
foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
|
||||
return newFoldLine;
|
||||
};
|
||||
}
|
||||
|
||||
this.merge = function(foldLineNext) {
|
||||
var folds = foldLineNext.folds;
|
||||
|
|
@ -224,7 +222,7 @@ function FoldLine(foldData, folds) {
|
|||
// it's merged now with foldLineNext.
|
||||
var foldData = this.foldData;
|
||||
foldData.splice(foldData.indexOf(foldLineNext), 1);
|
||||
};
|
||||
}
|
||||
|
||||
this.toString = function() {
|
||||
var ret = [this.range.toString() + ": [" ];
|
||||
|
|
@ -232,12 +230,13 @@ function FoldLine(foldData, folds) {
|
|||
this.folds.forEach(function(fold) {
|
||||
ret.push(" " + fold.toString());
|
||||
});
|
||||
ret.push("]");
|
||||
ret.push("]")
|
||||
return ret.join("\n");
|
||||
};
|
||||
}
|
||||
|
||||
this.idxToPosition = function(idx) {
|
||||
var lastFoldEndColumn = 0;
|
||||
var fold;
|
||||
|
||||
for (var i = 0; i < this.folds.length; i++) {
|
||||
var fold = this.folds[i];
|
||||
|
|
@ -262,7 +261,7 @@ function FoldLine(foldData, folds) {
|
|||
row: this.end.row,
|
||||
column: this.end.column + idx
|
||||
};
|
||||
};
|
||||
}
|
||||
}).call(FoldLine.prototype);
|
||||
|
||||
exports.FoldLine = FoldLine;
|
||||
|
|
|
|||
|
|
@ -289,12 +289,13 @@ function Folding() {
|
|||
if (startFold && endFold == startFold)
|
||||
return startFold.addSubFold(fold);
|
||||
|
||||
if (startFold && !startFold.range.isStart(startRow, startColumn))
|
||||
this.removeFold(startFold);
|
||||
|
||||
if (endFold && !endFold.range.isEnd(endRow, endColumn))
|
||||
this.removeFold(endFold);
|
||||
|
||||
if (
|
||||
(startFold && !startFold.range.isStart(startRow, startColumn))
|
||||
|| (endFold && !endFold.range.isEnd(endRow, endColumn))
|
||||
) {
|
||||
throw new Error("A fold can't intersect already existing fold" + fold.range + startFold.range);
|
||||
}
|
||||
|
||||
// Check if there are folds in the range we create the new fold for.
|
||||
var folds = this.getFoldsInRange(fold.range);
|
||||
if (folds.length > 0) {
|
||||
|
|
@ -696,8 +697,7 @@ function Folding() {
|
|||
|
||||
this.$foldMode = foldMode;
|
||||
|
||||
this.off('change', this.$updateFoldWidgets);
|
||||
this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
|
||||
this.removeListener('change', this.$updateFoldWidgets);
|
||||
this._emit("changeAnnotation");
|
||||
|
||||
if (!foldMode || this.$foldStyle == "manual") {
|
||||
|
|
@ -710,9 +710,8 @@ function Folding() {
|
|||
this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
|
||||
|
||||
this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
|
||||
this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
|
||||
this.on('change', this.$updateFoldWidgets);
|
||||
this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
|
||||
|
||||
};
|
||||
|
||||
this.getParentFoldRangeData = function (row, ignoreCurrent) {
|
||||
|
|
@ -794,7 +793,7 @@ function Folding() {
|
|||
this.foldAll(startRow, endRow, options.all ? 10000 : 0);
|
||||
} else if (options.children) {
|
||||
endRow = range ? range.end.row : this.getLength();
|
||||
this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
|
||||
this.foldAll(row + 1, range.end.row, options.all ? 10000 : 0);
|
||||
} else if (range) {
|
||||
if (options.all)
|
||||
range.collapseChildren = 10000;
|
||||
|
|
@ -829,13 +828,15 @@ function Folding() {
|
|||
}
|
||||
};
|
||||
|
||||
this.updateFoldWidgets = function(delta) {
|
||||
var firstRow = delta.start.row;
|
||||
var len = delta.end.row - firstRow;
|
||||
this.updateFoldWidgets = function(e) {
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
var firstRow = range.start.row;
|
||||
var len = range.end.row - firstRow;
|
||||
|
||||
if (len === 0) {
|
||||
this.foldWidgets[firstRow] = null;
|
||||
} else if (delta.action == 'remove') {
|
||||
} else if (delta.action == "removeText" || delta.action == "removeLines") {
|
||||
this.foldWidgets.splice(firstRow, len + 1, null);
|
||||
} else {
|
||||
var args = Array(len + 1);
|
||||
|
|
@ -843,13 +844,7 @@ function Folding() {
|
|||
this.foldWidgets.splice.apply(this.foldWidgets, args);
|
||||
}
|
||||
};
|
||||
this.tokenizerUpdateFoldWidgets = function(e) {
|
||||
var rows = e.data;
|
||||
if (rows.first != rows.last) {
|
||||
if (this.foldWidgets.length > rows.first)
|
||||
this.foldWidgets.splice(rows.first, this.foldWidgets.length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.Folding = Folding;
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ module.exports = {
|
|||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(12, 12);
|
||||
session.adjustWrapLimit(80);
|
||||
session.setOption("wrapMethod", "text");
|
||||
|
||||
assert.position(session.documentToScreenPosition(0, 11), 0, 11);
|
||||
assert.position(session.documentToScreenPosition(0, 12), 1, 0);
|
||||
},
|
||||
|
|
@ -380,8 +380,7 @@ module.exports = {
|
|||
line = lang.stringTrimRight(line);
|
||||
var tokens = EditSession.prototype.$getDisplayTokens(line);
|
||||
var splits = EditSession.prototype.$computeWrapSplits(tokens, wrapLimit, tabSize);
|
||||
console.log("String:", line, "Result:", splits, "Expected:", assertEqual);
|
||||
|
||||
// console.log("String:", line, "Result:", splits, "Expected:", assertEqual);
|
||||
assert.ok(splits.length == assertEqual.length);
|
||||
for (var i = 0; i < splits.length; i++) {
|
||||
assert.ok(splits[i] == assertEqual[i]);
|
||||
|
|
@ -389,7 +388,6 @@ module.exports = {
|
|||
}
|
||||
|
||||
EditSession.prototype.$wrapAsCode = true;
|
||||
EditSession.prototype.$indentedSoftWrap = false;
|
||||
// Basic splitting.
|
||||
computeAndAssert("foo bar foo bar", [ 12 ]);
|
||||
computeAndAssert("foo bar f bar", [ 12 ]);
|
||||
|
|
@ -415,26 +413,16 @@ module.exports = {
|
|||
computeAndAssert("ぁぁ", [1], 2);
|
||||
computeAndAssert(" ぁぁ", [1, 2], 2);
|
||||
computeAndAssert(" ぁ\tぁ", [1, 3], 2);
|
||||
computeAndAssert(" ぁぁ\tぁ", [2, 4], 4);
|
||||
computeAndAssert("ぁぁ ぁぁ\tぁ", [3, 6], 6);
|
||||
computeAndAssert(" ぁぁ\tぁ", [1, 4], 4);
|
||||
|
||||
// Test wrapping for punctuation.
|
||||
computeAndAssert(" ab.c;ef++", [2, 4, 6, 8], 2);
|
||||
computeAndAssert(" ab.c;ef++", [3, 5, 8], 3);
|
||||
computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2);
|
||||
computeAndAssert(" a.b", [1, 2, 3], 1);
|
||||
computeAndAssert("#>>", [1, 2], 1);
|
||||
|
||||
// Test wrapping for punctuation in
|
||||
EditSession.prototype.$wrapAsCode = false;
|
||||
computeAndAssert("ab cde, Juhu kinners", [3, 8, 13, 19], 6);
|
||||
|
||||
// test indented wrapping
|
||||
EditSession.prototype.$indentedSoftWrap = true;
|
||||
computeAndAssert("foo bar foo bar foo bara foo", [12, 25]);
|
||||
computeAndAssert("fooooooooooooooooooooooooooo", [12, 24]);
|
||||
computeAndAssert("\t\tfoo bar fooooooooooobooooooo", [6, 10, 16, 22, 28]);
|
||||
computeAndAssert("\t\t\tfoo bar fooooooooooobooooooo", [3, 7, 11, 17, 23, 29]);
|
||||
computeAndAssert("\tfoo \t \t \t \t bar", [6, 12]); // 14
|
||||
},
|
||||
|
||||
"test get longest line" : function() {
|
||||
|
|
@ -442,12 +430,12 @@ module.exports = {
|
|||
session.setTabSize(4);
|
||||
assert.equal(session.getScreenWidth(), 2);
|
||||
|
||||
session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']);
|
||||
session.doc.insertFullLines(1, ["123"]);
|
||||
session.doc.insertNewLine({row: 0, column: Infinity});
|
||||
session.doc.insertLines(1, ["123"]);
|
||||
assert.equal(session.getScreenWidth(), 3);
|
||||
|
||||
session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']);
|
||||
session.doc.insertFullLines(1, ["\t\t"]);
|
||||
session.doc.insertNewLine({row: 0, column: Infinity});
|
||||
session.doc.insertLines(1, ["\t\t"]);
|
||||
|
||||
assert.equal(session.getScreenWidth(), 8);
|
||||
|
||||
|
|
@ -471,9 +459,9 @@ module.exports = {
|
|||
|
||||
session.setUseWrapMode(true);
|
||||
|
||||
document.insertFullLines(0, ["a", "b"]);
|
||||
document.insertFullLines(2, ["c", "d"]);
|
||||
document.removeFullLines(1, 2);
|
||||
document.insertLines(0, ["a", "b"]);
|
||||
document.insertLines(2, ["c", "d"]);
|
||||
document.removeLines(1, 2);
|
||||
},
|
||||
|
||||
"test wrapMode init has to create wrapData array": function() {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ var Editor = function(renderer, session) {
|
|||
this.$mouseHandler = new MouseHandler(this);
|
||||
new FoldHandler(this);
|
||||
|
||||
this.$blockScrolling = 0;
|
||||
this.$search = new Search().set({
|
||||
wrap: true
|
||||
});
|
||||
|
|
@ -94,8 +93,7 @@ var Editor = function(renderer, session) {
|
|||
|
||||
this._$emitInputEvent = lang.delayedCall(function() {
|
||||
this._signal("input", {});
|
||||
if (this.session && this.session.bgTokenizer)
|
||||
this.session.bgTokenizer.scheduleStart();
|
||||
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart();
|
||||
}.bind(this));
|
||||
|
||||
this.on("change", function(_, _self) {
|
||||
|
|
@ -115,8 +113,30 @@ var Editor = function(renderer, session) {
|
|||
function last(a) {return a[a.length - 1]}
|
||||
|
||||
this.selections = [];
|
||||
this.commands.on("exec", this.startOperation.bind(this), true);
|
||||
this.commands.on("afterExec", this.endOperation.bind(this), true);
|
||||
this.commands.on("exec", function(e) {
|
||||
this.startOperation(e);
|
||||
|
||||
var command = e.command;
|
||||
if (command.aceCommandGroup == "fileJump") {
|
||||
var prev = this.prevOp;
|
||||
if (!prev || prev.command.aceCommandGroup != "fileJump") {
|
||||
this.lastFileJumpPos = last(this.selections);
|
||||
}
|
||||
} else {
|
||||
this.lastFileJumpPos = null;
|
||||
}
|
||||
}.bind(this), true);
|
||||
|
||||
this.commands.on("afterExec", function(e) {
|
||||
var command = e.command;
|
||||
|
||||
if (command.aceCommandGroup == "fileJump") {
|
||||
if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
|
||||
this.selection.fromJSON(this.lastFileJumpPos);
|
||||
}
|
||||
}
|
||||
this.endOperation(e);
|
||||
}.bind(this), true);
|
||||
|
||||
this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
|
||||
|
||||
|
|
@ -150,24 +170,19 @@ var Editor = function(renderer, session) {
|
|||
args: commadEvent.args,
|
||||
scrollTop: this.renderer.scrollTop
|
||||
};
|
||||
if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
|
||||
|
||||
var command = this.curOp.command;
|
||||
if (command && command.scrollIntoView)
|
||||
this.$blockScrolling++;
|
||||
|
||||
this.selections.push(this.selection.toJSON());
|
||||
};
|
||||
|
||||
this.endOperation = function(e) {
|
||||
this.endOperation = function() {
|
||||
if (this.curOp) {
|
||||
if (e && e.returnValue === false)
|
||||
return this.curOp = null;
|
||||
this._signal("beforeEndOperation");
|
||||
var command = this.curOp.command;
|
||||
if (command.name && this.$blockScrolling > 0)
|
||||
this.$blockScrolling--;
|
||||
var scrollIntoView = command && command.scrollIntoView;
|
||||
if (scrollIntoView) {
|
||||
switch (scrollIntoView) {
|
||||
case "center-animate":
|
||||
scrollIntoView = "animate";
|
||||
/* fall through */
|
||||
if (command && command.scrollIntoView) {
|
||||
switch (command.scrollIntoView) {
|
||||
case "center":
|
||||
this.renderer.scrollCursorIntoView(null, 0.5);
|
||||
break;
|
||||
|
|
@ -185,7 +200,7 @@ var Editor = function(renderer, session) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (scrollIntoView == "animate")
|
||||
if (command.scrollIntoView == "animate")
|
||||
this.renderer.animateScrolling(this.curOp.scrollTop);
|
||||
}
|
||||
|
||||
|
|
@ -237,19 +252,19 @@ var Editor = function(renderer, session) {
|
|||
* @param {String} keyboardHandler The new key handler
|
||||
*
|
||||
**/
|
||||
this.setKeyboardHandler = function(keyboardHandler, cb) {
|
||||
if (keyboardHandler && typeof keyboardHandler === "string") {
|
||||
this.setKeyboardHandler = function(keyboardHandler) {
|
||||
if (!keyboardHandler) {
|
||||
this.keyBinding.setKeyboardHandler(null);
|
||||
} else if (typeof keyboardHandler === "string") {
|
||||
this.$keybindingId = keyboardHandler;
|
||||
var _self = this;
|
||||
config.loadModule(["keybinding", keyboardHandler], function(module) {
|
||||
if (_self.$keybindingId == keyboardHandler)
|
||||
_self.keyBinding.setKeyboardHandler(module && module.handler);
|
||||
cb && cb();
|
||||
});
|
||||
} else {
|
||||
this.$keybindingId = null;
|
||||
this.keyBinding.setKeyboardHandler(keyboardHandler);
|
||||
cb && cb();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -278,10 +293,6 @@ var Editor = function(renderer, session) {
|
|||
this.setSession = function(session) {
|
||||
if (this.session == session)
|
||||
return;
|
||||
|
||||
// make sure operationEnd events are not emitted to wrong session
|
||||
if (this.curOp) this.endOperation();
|
||||
this.curOp = {};
|
||||
|
||||
var oldSession = this.session;
|
||||
if (oldSession) {
|
||||
|
|
@ -358,9 +369,7 @@ var Editor = function(renderer, session) {
|
|||
|
||||
this.onChangeMode();
|
||||
|
||||
this.$blockScrolling += 1;
|
||||
this.onCursorChange();
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
this.onScrollTopChange();
|
||||
this.onScrollLeftChange();
|
||||
|
|
@ -371,9 +380,6 @@ var Editor = function(renderer, session) {
|
|||
this.onChangeAnnotation();
|
||||
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
|
||||
this.renderer.updateFull();
|
||||
} else {
|
||||
this.selection = null;
|
||||
this.renderer.setSession(session);
|
||||
}
|
||||
|
||||
this._signal("changeSession", {
|
||||
|
|
@ -381,8 +387,6 @@ var Editor = function(renderer, session) {
|
|||
oldSession: oldSession
|
||||
});
|
||||
|
||||
this.curOp = null;
|
||||
|
||||
oldSession && oldSession._signal("changeEditor", {oldEditor: this});
|
||||
session && session._signal("changeEditor", {editor: this});
|
||||
};
|
||||
|
|
@ -517,23 +521,25 @@ var Editor = function(renderer, session) {
|
|||
this.$highlightPending = true;
|
||||
setTimeout(function() {
|
||||
self.$highlightPending = false;
|
||||
var session = self.session;
|
||||
if (!session || !session.bgTokenizer) return;
|
||||
var pos = session.findMatchingBracket(self.getCursorPosition());
|
||||
|
||||
var pos = self.session.findMatchingBracket(self.getCursorPosition());
|
||||
if (pos) {
|
||||
var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
|
||||
} else if (session.$mode.getMatching) {
|
||||
var range = session.$mode.getMatching(self.session);
|
||||
var range = new Range(pos.row, pos.column, pos.row, pos.column+1);
|
||||
} else if (self.session.$mode.getMatching) {
|
||||
var range = self.session.$mode.getMatching(self.session);
|
||||
}
|
||||
if (range)
|
||||
session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
|
||||
self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text");
|
||||
}, 50);
|
||||
};
|
||||
|
||||
// todo: move to mode.getMatching
|
||||
this.$highlightTags = function() {
|
||||
if (this.$highlightTagPending)
|
||||
var session = this.session;
|
||||
|
||||
if (this.$highlightTagPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
// perform highlight async to not block the browser during navigation
|
||||
var self = this;
|
||||
|
|
@ -541,25 +547,16 @@ var Editor = function(renderer, session) {
|
|||
setTimeout(function() {
|
||||
self.$highlightTagPending = false;
|
||||
|
||||
var session = self.session;
|
||||
if (!session || !session.bgTokenizer) return;
|
||||
|
||||
var pos = self.getCursorPosition();
|
||||
var iterator = new TokenIterator(self.session, pos.row, pos.column);
|
||||
var token = iterator.getCurrentToken();
|
||||
|
||||
if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
|
||||
if (!token || token.type.indexOf('tag-name') === -1) {
|
||||
session.removeMarker(session.$tagHighlight);
|
||||
session.$tagHighlight = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (token.type.indexOf("tag-open") != -1) {
|
||||
token = iterator.stepForward();
|
||||
if (!token)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var tag = token.value;
|
||||
var depth = 0;
|
||||
var prevToken = iterator.stepBackward();
|
||||
|
|
@ -571,28 +568,28 @@ var Editor = function(renderer, session) {
|
|||
token = iterator.stepForward();
|
||||
|
||||
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
|
||||
if (prevToken.value === '<'){
|
||||
if (prevToken.value==='<'){
|
||||
depth++;
|
||||
} else if (prevToken.value === '</'){
|
||||
} else if (prevToken.value==='</'){
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
|
||||
} while (token && depth >= 0);
|
||||
} else {
|
||||
} while (token && depth>=0);
|
||||
}else{
|
||||
//find opening tag
|
||||
do {
|
||||
token = prevToken;
|
||||
prevToken = iterator.stepBackward();
|
||||
|
||||
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
|
||||
if (prevToken.value === '<') {
|
||||
if(token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
|
||||
if (prevToken.value==='<') {
|
||||
depth++;
|
||||
} else if (prevToken.value === '</') {
|
||||
} else if( prevToken.value==='</') {
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
} while (prevToken && depth <= 0);
|
||||
} while (prevToken && depth<=0);
|
||||
|
||||
//select tag again
|
||||
iterator.stepForward();
|
||||
|
|
@ -656,13 +653,13 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.onFocus = function(e) {
|
||||
this.onFocus = function() {
|
||||
if (this.$isFocused)
|
||||
return;
|
||||
this.$isFocused = true;
|
||||
this.renderer.showCursor();
|
||||
this.renderer.visualizeFocus();
|
||||
this._emit("focus", e);
|
||||
this._emit("focus");
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -671,13 +668,13 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.onBlur = function(e) {
|
||||
this.onBlur = function() {
|
||||
if (!this.$isFocused)
|
||||
return;
|
||||
this.$isFocused = false;
|
||||
this.renderer.hideCursor();
|
||||
this.renderer.visualizeBlur();
|
||||
this._emit("blur", e);
|
||||
this._emit("blur");
|
||||
};
|
||||
|
||||
this.$cursorChange = function() {
|
||||
|
|
@ -692,15 +689,20 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.onDocumentChange = function(delta) {
|
||||
// Rerender and emit "change" event.
|
||||
var wrap = this.session.$useWrapMode;
|
||||
var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
|
||||
this.renderer.updateLines(delta.start.row, lastRow, wrap);
|
||||
this.onDocumentChange = function(e) {
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
var lastRow;
|
||||
|
||||
this._signal("change", delta);
|
||||
|
||||
// Update cursor because tab characters can influence the cursor position.
|
||||
if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
|
||||
lastRow = range.end.row;
|
||||
else
|
||||
lastRow = Infinity;
|
||||
this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode);
|
||||
|
||||
this._signal("change", e);
|
||||
|
||||
// update cursor because tab characters can influence the cursor position
|
||||
this.$cursorChange();
|
||||
this.$updateHighlightActiveLine();
|
||||
};
|
||||
|
|
@ -726,14 +728,6 @@ var Editor = function(renderer, session) {
|
|||
this.onCursorChange = function() {
|
||||
this.$cursorChange();
|
||||
|
||||
if (!this.$blockScrolling) {
|
||||
config.warn("Automatically scrolling cursor into view after selection change",
|
||||
"this will be disabled in the next version",
|
||||
"set editor.$blockScrolling = Infinity to disable this message"
|
||||
);
|
||||
this.renderer.scrollCursorIntoView();
|
||||
}
|
||||
|
||||
this.$highlightBrackets();
|
||||
this.$highlightTags();
|
||||
this.$updateHighlightActiveLine();
|
||||
|
|
@ -905,7 +899,7 @@ var Editor = function(renderer, session) {
|
|||
/**
|
||||
* Emitted when text is pasted.
|
||||
* @event paste
|
||||
* @param {Object} an object which contains one property, `text`, that represents the text to be pasted. Editing this property will alter the text that is pasted.
|
||||
* @param {String} text The pasted text
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
|
@ -915,16 +909,14 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.onPaste = function(text, event) {
|
||||
var e = {text: text, event: event};
|
||||
this.commands.exec("paste", this, e);
|
||||
};
|
||||
|
||||
this.$handlePaste = function(e) {
|
||||
if (typeof e == "string")
|
||||
e = {text: e};
|
||||
this.onPaste = function(text) {
|
||||
// todo this should change when paste becomes a command
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
var e = {text: text};
|
||||
this._signal("paste", e);
|
||||
var text = e.text;
|
||||
text = e.text;
|
||||
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
|
||||
this.insert(text);
|
||||
} else {
|
||||
|
|
@ -942,10 +934,12 @@ var Editor = function(renderer, session) {
|
|||
this.session.insert(range.start, lines[i]);
|
||||
}
|
||||
}
|
||||
this.renderer.scrollCursorIntoView();
|
||||
};
|
||||
|
||||
|
||||
this.execCommand = function(command, args) {
|
||||
return this.commands.exec(command, this, args);
|
||||
this.commands.exec(command, this, args);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1297,7 +1291,7 @@ var Editor = function(renderer, session) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Removes the current selection or one character.
|
||||
* Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace.
|
||||
* @param {String} dir The direction of the deletion to occur, either "left" or "right"
|
||||
*
|
||||
**/
|
||||
|
|
@ -1629,7 +1623,15 @@ var Editor = function(renderer, session) {
|
|||
**/
|
||||
this.removeLines = function() {
|
||||
var rows = this.$getSelectedRows();
|
||||
this.session.removeFullLines(rows.first, rows.last);
|
||||
var range;
|
||||
if (rows.first === 0 || rows.last+1 < this.session.getLength())
|
||||
range = new Range(rows.first, 0, rows.last+1, 0);
|
||||
else
|
||||
range = new Range(
|
||||
rows.first-1, this.session.getLine(rows.first-1).length,
|
||||
rows.last, this.session.getLine(rows.last).length
|
||||
);
|
||||
this.session.remove(range);
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
|
@ -1658,7 +1660,9 @@ var Editor = function(renderer, session) {
|
|||
* @related EditSession.moveLinesUp
|
||||
**/
|
||||
this.moveLinesDown = function() {
|
||||
this.$moveLines(1, false);
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.session.moveLinesDown(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1667,7 +1671,9 @@ var Editor = function(renderer, session) {
|
|||
* @related EditSession.moveLinesDown
|
||||
**/
|
||||
this.moveLinesUp = function() {
|
||||
this.$moveLines(-1, false);
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.session.moveLinesUp(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1691,7 +1697,10 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
**/
|
||||
this.copyLinesUp = function() {
|
||||
this.$moveLines(-1, true);
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
this.session.duplicateLines(firstRow, lastRow);
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1701,61 +1710,51 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
**/
|
||||
this.copyLinesDown = function() {
|
||||
this.$moveLines(1, true);
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.session.duplicateLines(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* for internal use
|
||||
* @ignore
|
||||
* Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them.
|
||||
* @param {Function} mover A method to call on each selected row
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.$moveLines = function(dir, copy) {
|
||||
var rows, moved;
|
||||
this.$moveLines = function(mover) {
|
||||
var selection = this.selection;
|
||||
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
|
||||
var range = selection.toOrientedRange();
|
||||
rows = this.$getSelectedRows(range);
|
||||
moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
|
||||
if (copy && dir == -1) moved = 0;
|
||||
range.moveBy(moved, 0);
|
||||
var rows = this.$getSelectedRows(range);
|
||||
var linesMoved = mover.call(this, rows.first, rows.last);
|
||||
range.moveBy(linesMoved, 0);
|
||||
selection.fromOrientedRange(range);
|
||||
} else {
|
||||
var ranges = selection.rangeList.ranges;
|
||||
selection.rangeList.detach(this.session);
|
||||
this.inVirtualSelectionMode = true;
|
||||
|
||||
var diff = 0;
|
||||
var totalDiff = 0;
|
||||
var l = ranges.length;
|
||||
for (var i = 0; i < l; i++) {
|
||||
|
||||
for (var i = ranges.length; i--; ) {
|
||||
var rangeIndex = i;
|
||||
ranges[i].moveBy(diff, 0);
|
||||
rows = this.$getSelectedRows(ranges[i]);
|
||||
var first = rows.first;
|
||||
var last = rows.last;
|
||||
while (++i < l) {
|
||||
if (totalDiff) ranges[i].moveBy(totalDiff, 0);
|
||||
var subRows = this.$getSelectedRows(ranges[i]);
|
||||
if (copy && subRows.first != last)
|
||||
var rows = ranges[i].collapseRows();
|
||||
var last = rows.end.row;
|
||||
var first = rows.start.row;
|
||||
while (i--) {
|
||||
rows = ranges[i].collapseRows();
|
||||
if (first - rows.end.row <= 1)
|
||||
first = rows.end.row;
|
||||
else
|
||||
break;
|
||||
else if (!copy && subRows.first > last + 1)
|
||||
break;
|
||||
last = subRows.last;
|
||||
}
|
||||
i--;
|
||||
diff = this.session.$moveLines(first, last, copy ? 0 : dir);
|
||||
if (copy && dir == -1) rangeIndex = i + 1;
|
||||
while (rangeIndex <= i) {
|
||||
ranges[rangeIndex].moveBy(diff, 0);
|
||||
rangeIndex++;
|
||||
i++;
|
||||
|
||||
var linesMoved = mover.call(this, first, last);
|
||||
while (rangeIndex >= i) {
|
||||
ranges[rangeIndex].moveBy(linesMoved, 0);
|
||||
rangeIndex--;
|
||||
}
|
||||
if (!copy) diff = 0;
|
||||
totalDiff += diff;
|
||||
}
|
||||
|
||||
selection.fromOrientedRange(selection.ranges[0]);
|
||||
selection.rangeList.attach(this.session);
|
||||
this.inVirtualSelectionMode = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1768,8 +1767,8 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
* @returns {Object}
|
||||
**/
|
||||
this.$getSelectedRows = function(range) {
|
||||
range = (range || this.getSelectionRange()).collapseRows();
|
||||
this.$getSelectedRows = function() {
|
||||
var range = this.getSelectionRange().collapseRows();
|
||||
|
||||
return {
|
||||
first: this.session.getRowFoldStart(range.start.row),
|
||||
|
|
@ -1843,7 +1842,6 @@ var Editor = function(renderer, session) {
|
|||
var config = this.renderer.layerConfig;
|
||||
var rows = dir * Math.floor(config.height / config.lineHeight);
|
||||
|
||||
this.$blockScrolling++;
|
||||
if (select === true) {
|
||||
this.selection.$moveSelection(function(){
|
||||
this.moveCursorBy(rows, 0);
|
||||
|
|
@ -1852,7 +1850,6 @@ var Editor = function(renderer, session) {
|
|||
this.selection.moveCursorBy(rows, 0);
|
||||
this.selection.clearSelection();
|
||||
}
|
||||
this.$blockScrolling--;
|
||||
|
||||
var scrollTop = renderer.scrollTop;
|
||||
|
||||
|
|
@ -1977,9 +1974,7 @@ var Editor = function(renderer, session) {
|
|||
* @related Selection.selectAll
|
||||
**/
|
||||
this.selectAll = function() {
|
||||
this.$blockScrolling += 1;
|
||||
this.selection.selectAll();
|
||||
this.$blockScrolling -= 1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2017,13 +2012,17 @@ var Editor = function(renderer, session) {
|
|||
* Moves the cursor's row and column to the next matching bracket or HTML tag.
|
||||
*
|
||||
**/
|
||||
this.jumpToMatching = function(select, expand) {
|
||||
this.jumpToMatching = function(select) {
|
||||
var cursor = this.getCursorPosition();
|
||||
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
|
||||
var prevToken = iterator.getCurrentToken();
|
||||
var token = prevToken || iterator.stepForward();
|
||||
var token = prevToken;
|
||||
|
||||
if (!token) return;
|
||||
if (!token)
|
||||
token = iterator.stepForward();
|
||||
|
||||
if (!token)
|
||||
return;
|
||||
|
||||
//get next closing tag or bracket
|
||||
var matchType;
|
||||
|
|
@ -2042,12 +2041,12 @@ var Editor = function(renderer, session) {
|
|||
|
||||
do {
|
||||
if (token.value.match(/[{}()\[\]]/g)) {
|
||||
for (; i < token.value.length && !found; i++) {
|
||||
for (; i<token.value.length && !found; i++) {
|
||||
if (!brackets[token.value[i]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
|
||||
bracketType = brackets[token.value[i]]+'.'+token.type.replace("rparen", "lparen");
|
||||
|
||||
if (isNaN(depth[bracketType])) {
|
||||
depth[bracketType] = 0;
|
||||
|
|
@ -2058,29 +2057,27 @@ var Editor = function(renderer, session) {
|
|||
case '[':
|
||||
case '{':
|
||||
depth[bracketType]++;
|
||||
break;
|
||||
break;
|
||||
case ')':
|
||||
case ']':
|
||||
case '}':
|
||||
depth[bracketType]--;
|
||||
|
||||
if (depth[bracketType] === -1) {
|
||||
|
||||
if (depth[bracketType]===-1) {
|
||||
matchType = 'bracket';
|
||||
found = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token && token.type.indexOf('tag-name') !== -1) {
|
||||
} else if (token && token.type.indexOf('tag-name') !== -1) {
|
||||
if (isNaN(depth[token.value])) {
|
||||
depth[token.value] = 0;
|
||||
}
|
||||
|
||||
if (prevToken.value === '<') {
|
||||
depth[token.value]++;
|
||||
}
|
||||
else if (prevToken.value === '</') {
|
||||
} else if (prevToken.value === '</') {
|
||||
depth[token.value]--;
|
||||
}
|
||||
|
||||
|
|
@ -2098,35 +2095,37 @@ var Editor = function(renderer, session) {
|
|||
} while (token && !found);
|
||||
|
||||
//no match found
|
||||
if (!matchType)
|
||||
if (!matchType) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range, pos;
|
||||
if (matchType === 'bracket') {
|
||||
var range;
|
||||
if (matchType==='bracket') {
|
||||
range = this.session.getBracketRange(cursor);
|
||||
if (!range) {
|
||||
range = new Range(
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn() + i - 1,
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn() + i - 1
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()+i-1,
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()+i-1
|
||||
);
|
||||
pos = range.start;
|
||||
if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
|
||||
if (!range)
|
||||
return;
|
||||
var pos = range.start;
|
||||
if (pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
|
||||
range = this.session.getBracketRange(pos);
|
||||
}
|
||||
}
|
||||
else if (matchType === 'tag') {
|
||||
if (token && token.type.indexOf('tag-name') !== -1)
|
||||
} else if(matchType==='tag') {
|
||||
if (token && token.type.indexOf('tag-name') !== -1)
|
||||
var tag = token.value;
|
||||
else
|
||||
return;
|
||||
|
||||
range = new Range(
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn() - 2,
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn() - 2
|
||||
var range = new Range(
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()-2,
|
||||
iterator.getCurrentTokenRow(),
|
||||
iterator.getCurrentTokenColumn()-2
|
||||
);
|
||||
|
||||
//find matching tag
|
||||
|
|
@ -2138,18 +2137,17 @@ var Editor = function(renderer, session) {
|
|||
|
||||
if (prevToken) {
|
||||
if (prevToken.type.indexOf('tag-close') !== -1) {
|
||||
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
|
||||
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn()+1);
|
||||
}
|
||||
|
||||
if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
|
||||
if (prevToken.value === '<') {
|
||||
depth[tag]++;
|
||||
}
|
||||
else if (prevToken.value === '</') {
|
||||
} else if ( prevToken.value === '</') {
|
||||
depth[tag]--;
|
||||
}
|
||||
|
||||
if (depth[tag] === 0)
|
||||
if (depth[tag]===0)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2158,7 +2156,7 @@ var Editor = function(renderer, session) {
|
|||
|
||||
//we found it
|
||||
if (token && token.type.indexOf('tag-name')) {
|
||||
pos = range.start;
|
||||
var pos = range.start;
|
||||
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
|
||||
pos = range.end;
|
||||
}
|
||||
|
|
@ -2167,13 +2165,10 @@ var Editor = function(renderer, session) {
|
|||
pos = range && range.cursor || pos;
|
||||
if (pos) {
|
||||
if (select) {
|
||||
if (range && expand) {
|
||||
this.selection.setRange(range);
|
||||
} else if (range && range.isEqual(this.getSelectionRange())) {
|
||||
if (range && range.isEqual(this.getSelectionRange()))
|
||||
this.clearSelection();
|
||||
} else {
|
||||
else
|
||||
this.selection.selectTo(pos.row, pos.column);
|
||||
}
|
||||
} else {
|
||||
this.selection.moveTo(pos.row, pos.column);
|
||||
}
|
||||
|
|
@ -2191,11 +2186,9 @@ var Editor = function(renderer, session) {
|
|||
this.selection.clearSelection();
|
||||
this.session.unfold({row: lineNumber - 1, column: column || 0});
|
||||
|
||||
this.$blockScrolling += 1;
|
||||
// todo: find a way to automatically exit multiselect mode
|
||||
this.exitMultiSelectMode && this.exitMultiSelectMode();
|
||||
this.moveCursorTo(lineNumber - 1, column || 0);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
if (!this.isRowFullyVisible(lineNumber - 1))
|
||||
this.scrollToLine(lineNumber - 1, true, animate);
|
||||
|
|
@ -2381,7 +2374,6 @@ var Editor = function(renderer, session) {
|
|||
if (!ranges.length)
|
||||
return replaced;
|
||||
|
||||
this.$blockScrolling += 1;
|
||||
|
||||
var selection = this.getSelectionRange();
|
||||
this.selection.moveTo(0, 0);
|
||||
|
|
@ -2393,7 +2385,6 @@ var Editor = function(renderer, session) {
|
|||
}
|
||||
|
||||
this.selection.setSelectionRange(selection);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
return replaced;
|
||||
};
|
||||
|
|
@ -2491,10 +2482,8 @@ var Editor = function(renderer, session) {
|
|||
};
|
||||
|
||||
this.revealRange = function(range, animate) {
|
||||
this.$blockScrolling += 1;
|
||||
this.session.unfold(range);
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
var scrollTop = this.renderer.scrollTop;
|
||||
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
|
||||
|
|
@ -2507,9 +2496,7 @@ var Editor = function(renderer, session) {
|
|||
* @related UndoManager.undo
|
||||
**/
|
||||
this.undo = function() {
|
||||
this.$blockScrolling++;
|
||||
this.session.getUndoManager().undo();
|
||||
this.$blockScrolling--;
|
||||
this.renderer.scrollCursorIntoView(null, 0.5);
|
||||
};
|
||||
|
||||
|
|
@ -2518,9 +2505,7 @@ var Editor = function(renderer, session) {
|
|||
* @related UndoManager.redo
|
||||
**/
|
||||
this.redo = function() {
|
||||
this.$blockScrolling++;
|
||||
this.session.getUndoManager().redo();
|
||||
this.$blockScrolling--;
|
||||
this.renderer.scrollCursorIntoView(null, 0.5);
|
||||
};
|
||||
|
||||
|
|
@ -2531,9 +2516,6 @@ var Editor = function(renderer, session) {
|
|||
this.destroy = function() {
|
||||
this.renderer.destroy();
|
||||
this._signal("destroy", this);
|
||||
if (this.session) {
|
||||
this.session.destroy();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2560,9 +2542,7 @@ var Editor = function(renderer, session) {
|
|||
rect = self.renderer.container.getBoundingClientRect();
|
||||
});
|
||||
var onAfterRender = this.renderer.on("afterRender", function() {
|
||||
if (shouldScroll && rect && (self.isFocused()
|
||||
|| self.searchBox && self.searchBox.isFocused())
|
||||
) {
|
||||
if (shouldScroll && rect && self.isFocused()) {
|
||||
var renderer = self.renderer;
|
||||
var pos = renderer.$cursorLayer.$pixelPos;
|
||||
var config = renderer.layerConfig;
|
||||
|
|
@ -2682,7 +2662,6 @@ config.defineOptions(Editor.prototype, "editor", {
|
|||
useSoftTabs: "session",
|
||||
tabSize: "session",
|
||||
wrap: "session",
|
||||
indentedSoftWrap: "session",
|
||||
foldStyle: "session",
|
||||
mode: "session"
|
||||
});
|
||||
|
|
|
|||
|
|
@ -578,14 +578,15 @@ var onSelectionChange = function(evt) {
|
|||
* and deleting text.
|
||||
* @param {!Event} evt The event.
|
||||
*/
|
||||
var onChange = function(delta) {
|
||||
var onChange = function(evt) {
|
||||
var data = evt.data;
|
||||
switch (data.action) {
|
||||
case 'remove':
|
||||
case 'removeText':
|
||||
cvox.Api.speak(data.text, 0, DELETED_PROP);
|
||||
/* Let the future cursor change event know it's from text change. */
|
||||
changed = true;
|
||||
break;
|
||||
case 'insert':
|
||||
case 'insertText':
|
||||
cvox.Api.speak(data.text, 0);
|
||||
/* Let the future cursor change event know it's from text change. */
|
||||
changed = true;
|
||||
|
|
|
|||
|
|
@ -44,12 +44,13 @@ var ElasticTabstopsLite = function(editor) {
|
|||
this.onExec = function() {
|
||||
recordChanges = true;
|
||||
};
|
||||
this.onChange = function(delta) {
|
||||
this.onChange = function(e) {
|
||||
var range = e.data.range
|
||||
if (recordChanges) {
|
||||
if (changedRows.indexOf(delta.start.row) == -1)
|
||||
changedRows.push(delta.start.row);
|
||||
if (delta.end.row != delta.start.row)
|
||||
changedRows.push(delta.end.row);
|
||||
if (changedRows.indexOf(range.start.row) == -1)
|
||||
changedRows.push(range.start.row);
|
||||
if (range.end.row != range.start.row)
|
||||
changedRows.push(range.end.row);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,15 @@ var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
|
|||
var Editor = require("ace/editor").Editor;
|
||||
var snippetManager = require("ace/snippets").snippetManager;
|
||||
var Range = require("ace/range").Range;
|
||||
var emmet, emmetPath;
|
||||
var emmet;
|
||||
|
||||
Editor.prototype.indexToPosition = function(index) {
|
||||
return this.session.doc.indexToPosition(index);
|
||||
};
|
||||
|
||||
Editor.prototype.positionToIndex = function(pos) {
|
||||
return this.session.doc.positionToIndex(pos);
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of {@link IEmmetEditor} interface for Ace
|
||||
|
|
@ -64,10 +72,9 @@ AceEmmetEditor.prototype = {
|
|||
getSelectionRange: function() {
|
||||
// TODO should start be caret position instead?
|
||||
var range = this.ace.getSelectionRange();
|
||||
var doc = this.ace.session.doc;
|
||||
return {
|
||||
start: doc.positionToIndex(range.start),
|
||||
end: doc.positionToIndex(range.end)
|
||||
start: this.ace.positionToIndex(range.start),
|
||||
end: this.ace.positionToIndex(range.end)
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -84,10 +91,9 @@ AceEmmetEditor.prototype = {
|
|||
* editor.createSelection(15);
|
||||
*/
|
||||
createSelection: function(start, end) {
|
||||
var doc = this.ace.session.doc;
|
||||
this.ace.selection.setRange({
|
||||
start: doc.indexToPosition(start),
|
||||
end: doc.indexToPosition(end)
|
||||
start: this.ace.indexToPosition(start),
|
||||
end: this.ace.indexToPosition(end)
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -100,10 +106,9 @@ AceEmmetEditor.prototype = {
|
|||
* alert(range.start + ', ' + range.end);
|
||||
*/
|
||||
getCurrentLineRange: function() {
|
||||
var ace = this.ace;
|
||||
var row = ace.getCursorPosition().row;
|
||||
var lineLength = ace.session.getLine(row).length;
|
||||
var index = ace.session.doc.positionToIndex({row: row, column: 0});
|
||||
var row = this.ace.getCursorPosition().row;
|
||||
var lineLength = this.ace.session.getLine(row).length;
|
||||
var index = this.ace.positionToIndex({row: row, column: 0});
|
||||
return {
|
||||
start: index,
|
||||
end: index + lineLength
|
||||
|
|
@ -116,7 +121,7 @@ AceEmmetEditor.prototype = {
|
|||
*/
|
||||
getCaretPos: function(){
|
||||
var pos = this.ace.getCursorPosition();
|
||||
return this.ace.session.doc.positionToIndex(pos);
|
||||
return this.ace.positionToIndex(pos);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -124,7 +129,7 @@ AceEmmetEditor.prototype = {
|
|||
* @param {Number} index Caret position
|
||||
*/
|
||||
setCaretPos: function(index){
|
||||
var pos = this.ace.session.doc.indexToPosition(index);
|
||||
var pos = this.ace.indexToPosition(index);
|
||||
this.ace.selection.moveToPosition(pos);
|
||||
},
|
||||
|
||||
|
|
@ -164,15 +169,14 @@ AceEmmetEditor.prototype = {
|
|||
start = 0;
|
||||
|
||||
var editor = this.ace;
|
||||
var doc = editor.session.doc;
|
||||
var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end));
|
||||
var range = Range.fromPoints(editor.indexToPosition(start), editor.indexToPosition(end));
|
||||
editor.session.remove(range);
|
||||
|
||||
range.end = range.start;
|
||||
//editor.selection.setRange(range);
|
||||
|
||||
value = this.$updateTabstops(value);
|
||||
snippetManager.insertSnippet(editor, value);
|
||||
snippetManager.insertSnippet(editor, value)
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -288,7 +292,7 @@ AceEmmetEditor.prototype = {
|
|||
lastZero = range.create(data.start, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result
|
||||
},
|
||||
escape: function(ch) {
|
||||
if (ch == '$') return '\\$';
|
||||
|
|
@ -342,34 +346,29 @@ var keymap = {
|
|||
var editorProxy = new AceEmmetEditor();
|
||||
exports.commands = new HashHandler();
|
||||
exports.runEmmetCommand = function(editor) {
|
||||
try {
|
||||
editorProxy.setupContext(editor);
|
||||
if (editorProxy.getSyntax() == "php")
|
||||
editorProxy.setupContext(editor);
|
||||
if (editorProxy.getSyntax() == "php")
|
||||
return false;
|
||||
var actions = emmet.require("actions");
|
||||
|
||||
if (this.action == "expand_abbreviation_with_tab") {
|
||||
if (!editor.selection.isEmpty())
|
||||
return false;
|
||||
var actions = emmet.require("actions");
|
||||
}
|
||||
|
||||
if (this.action == "expand_abbreviation_with_tab") {
|
||||
if (!editor.selection.isEmpty())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.action == "wrap_with_abbreviation") {
|
||||
// without setTimeout prompt doesn't work on firefox
|
||||
return setTimeout(function() {
|
||||
actions.run("wrap_with_abbreviation", editorProxy);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var pos = editor.selection.lead;
|
||||
var token = editor.session.getTokenAt(pos.row, pos.column);
|
||||
if (token && /\btag\b/.test(token.type))
|
||||
return false;
|
||||
|
||||
if (this.action == "wrap_with_abbreviation") {
|
||||
// without setTimeout prompt doesn't work on firefox
|
||||
return setTimeout(function() {
|
||||
actions.run("wrap_with_abbreviation", editorProxy);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
try {
|
||||
var result = actions.run(this.action, editorProxy);
|
||||
} catch(e) {
|
||||
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
||||
console.log(e);
|
||||
result = false;
|
||||
result = false
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
|
@ -384,35 +383,21 @@ for (var command in keymap) {
|
|||
});
|
||||
}
|
||||
|
||||
exports.updateCommands = function(editor, enabled) {
|
||||
if (enabled) {
|
||||
editor.keyBinding.addKeyboardHandler(exports.commands);
|
||||
} else {
|
||||
editor.keyBinding.removeKeyboardHandler(exports.commands);
|
||||
}
|
||||
};
|
||||
|
||||
exports.isSupportedMode = function(modeId) {
|
||||
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(modeId);
|
||||
};
|
||||
|
||||
var onChangeMode = function(e, target) {
|
||||
var editor = target;
|
||||
if (!editor)
|
||||
return;
|
||||
var enabled = exports.isSupportedMode(editor.session.$modeId);
|
||||
var modeId = editor.session.$modeId;
|
||||
var enabled = modeId && /css|less|scss|sass|stylus|html|php/.test(modeId);
|
||||
if (e.enableEmmet === false)
|
||||
enabled = false;
|
||||
if (enabled) {
|
||||
if (typeof emmetPath == "string") {
|
||||
require("ace/config").loadModule(emmetPath, function() {
|
||||
emmetPath = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.updateCommands(editor, enabled);
|
||||
if (enabled)
|
||||
editor.keyBinding.addKeyboardHandler(exports.commands);
|
||||
else
|
||||
editor.keyBinding.removeKeyboardHandler(exports.commands);
|
||||
};
|
||||
|
||||
|
||||
exports.AceEmmetEditor = AceEmmetEditor;
|
||||
require("ace/config").defineOptions(Editor.prototype, "editor", {
|
||||
enableEmmet: {
|
||||
|
|
@ -424,11 +409,7 @@ require("ace/config").defineOptions(Editor.prototype, "editor", {
|
|||
}
|
||||
});
|
||||
|
||||
exports.setCore = function(e) {
|
||||
if (typeof e == "string")
|
||||
emmetPath = e;
|
||||
else
|
||||
emmet = e;
|
||||
};
|
||||
|
||||
exports.setCore = function(e) {emmet = e;};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
var LineWidgets = require("../line_widgets").LineWidgets;
|
||||
var dom = require("../lib/dom");
|
||||
var Range = require("../range").Range;
|
||||
var LineWidgets = require("ace/line_widgets").LineWidgets;
|
||||
var dom = require("ace/lib/dom");
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
function binarySearch(array, needle, comparator) {
|
||||
var first = 0;
|
||||
|
|
@ -62,7 +62,7 @@ function findAnnotations(session, row, dir) {
|
|||
if (i < 0)
|
||||
i = -i - 1;
|
||||
|
||||
if (i >= annotations.length)
|
||||
if (i >= annotations.length - 1)
|
||||
i = dir > 0 ? 0 : annotations.length - 1;
|
||||
else if (i === 0 && dir < 0)
|
||||
i = annotations.length - 1;
|
||||
|
|
|
|||
|
|
@ -34,15 +34,11 @@ define(function(require, exports, module) {
|
|||
var snippetManager = require("../snippets").snippetManager;
|
||||
var Autocomplete = require("../autocomplete").Autocomplete;
|
||||
var config = require("../config");
|
||||
var lang = require("../lib/lang");
|
||||
var util = require("../autocomplete/util");
|
||||
|
||||
var textCompleter = require("../autocomplete/text_completer");
|
||||
var keyWordCompleter = {
|
||||
getCompletions: function(editor, session, pos, prefix, callback) {
|
||||
if (session.$mode.completer) {
|
||||
return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
|
||||
}
|
||||
var state = editor.session.getState(pos.row);
|
||||
var completions = session.$mode.getCompletions(state, session, pos, prefix);
|
||||
callback(null, completions);
|
||||
|
|
@ -63,29 +59,15 @@ var snippetCompleter = {
|
|||
completions.push({
|
||||
caption: caption,
|
||||
snippet: s.content,
|
||||
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet",
|
||||
type: "snippet"
|
||||
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet"
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
callback(null, completions);
|
||||
},
|
||||
getDocTooltip: function(item) {
|
||||
if (item.type == "snippet" && !item.docHTML) {
|
||||
item.docHTML = [
|
||||
"<b>", lang.escapeHTML(item.caption), "</b>", "<hr></hr>",
|
||||
lang.escapeHTML(item.snippet)
|
||||
].join("");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var completers = [snippetCompleter, textCompleter, keyWordCompleter];
|
||||
// Allows default completers to be removed or replaced with a explict set of completers
|
||||
// A null argument here will result in an empty completer array, not a null attribute
|
||||
exports.setCompleters = function(val) {
|
||||
completers = val || [];
|
||||
};
|
||||
exports.addCompleter = function(completer) {
|
||||
completers.push(completer);
|
||||
};
|
||||
|
|
@ -98,7 +80,9 @@ exports.snippetCompleter = snippetCompleter;
|
|||
var expandSnippet = {
|
||||
name: "expandSnippet",
|
||||
exec: function(editor) {
|
||||
return snippetManager.expandWithTab(editor);
|
||||
var success = snippetManager.expandWithTab(editor);
|
||||
if (!success)
|
||||
editor.execCommand("indent");
|
||||
},
|
||||
bindKey: "Tab"
|
||||
};
|
||||
|
|
@ -140,7 +124,7 @@ var loadSnippetFile = function(id) {
|
|||
function getCompletionPrefix(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
var line = editor.session.getLine(pos.row);
|
||||
var prefix;
|
||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||
// Try to find custom prefixes on the completers
|
||||
editor.completers.forEach(function(completer) {
|
||||
if (completer.identifierRegexps) {
|
||||
|
|
@ -150,13 +134,16 @@ function getCompletionPrefix(editor) {
|
|||
});
|
||||
}
|
||||
});
|
||||
return prefix || util.retrievePrecedingIdentifier(line, pos.column);
|
||||
return prefix;
|
||||
}
|
||||
|
||||
var doLiveAutocomplete = function(e) {
|
||||
var editor = e.editor;
|
||||
var text = e.args || "";
|
||||
var hasCompleter = editor.completer && editor.completer.activated;
|
||||
|
||||
|
||||
|
||||
// We don't want to autocomplete with no prefix
|
||||
if (e.command.name === "backspace") {
|
||||
if (hasCompleter && !getCompletionPrefix(editor))
|
||||
|
|
@ -171,6 +158,7 @@ var doLiveAutocomplete = function(e) {
|
|||
editor.completer = new Autocomplete();
|
||||
}
|
||||
// Disable autoInsert
|
||||
editor.completer.autoSelect = false;
|
||||
editor.completer.autoInsert = false;
|
||||
editor.completer.showPopup(editor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,12 +91,6 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
|
|||
elements.forEach(function(element) {
|
||||
topmenu.appendChild(element);
|
||||
});
|
||||
|
||||
var el = topmenu.appendChild(document.createElement('div'));
|
||||
var version = "1.1.9";
|
||||
el.style.padding = "1em";
|
||||
el.textContent = "Ace version " + version;
|
||||
|
||||
return topmenu;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -69,20 +69,29 @@ module.exports.getEditorKeybordShortcuts = function(editor) {
|
|||
editor.keyBinding.$handlers.forEach(function(handler) {
|
||||
var ckb = handler.commandKeyBinding;
|
||||
for (var i in ckb) {
|
||||
var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); });
|
||||
var commands = ckb[i];
|
||||
if (!Array.isArray(commands))
|
||||
commands = [commands];
|
||||
commands.forEach(function(command) {
|
||||
var modifier = parseInt(i);
|
||||
if (modifier == -1) {
|
||||
modifier = "";
|
||||
} else if(isNaN(modifier)) {
|
||||
modifier = i;
|
||||
} else {
|
||||
modifier = "" +
|
||||
(modifier & KEY_MODS.command ? "Cmd-" : "") +
|
||||
(modifier & KEY_MODS.ctrl ? "Ctrl-" : "") +
|
||||
(modifier & KEY_MODS.alt ? "Alt-" : "") +
|
||||
(modifier & KEY_MODS.shift ? "Shift-" : "");
|
||||
}
|
||||
for (var key in ckb[i]) {
|
||||
var command = ckb[i][key]
|
||||
if (typeof command != "string")
|
||||
command = command.name
|
||||
if (commandMap[command]) {
|
||||
commandMap[command].key += "|" + key;
|
||||
commandMap[command].key += "|" + modifier + key;
|
||||
} else {
|
||||
commandMap[command] = {key: key, command: command};
|
||||
commandMap[command] = {key: modifier+key, command: command};
|
||||
keybindings.push(commandMap[command]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return keybindings;
|
||||
|
|
|
|||
|
|
@ -43,11 +43,10 @@ Mode.prototype.supportsFile = function(filename) {
|
|||
// todo firstlinematch
|
||||
var supportedModes = {
|
||||
ABAP: ["abap"],
|
||||
ABC: ["abc"],
|
||||
ActionScript:["as"],
|
||||
ADA: ["ada|adb"],
|
||||
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
|
||||
AsciiDoc: ["asciidoc|adoc"],
|
||||
AsciiDoc: ["asciidoc"],
|
||||
Assembly_x86:["asm"],
|
||||
AutoHotKey: ["ahk"],
|
||||
BatchFile: ["bat|cmd"],
|
||||
|
|
@ -66,16 +65,11 @@ var supportedModes = {
|
|||
Diff: ["diff|patch"],
|
||||
Dockerfile: ["^Dockerfile"],
|
||||
Dot: ["dot"],
|
||||
Dummy: ["dummy"],
|
||||
DummySyntax: ["dummy"],
|
||||
Eiffel: ["e"],
|
||||
EJS: ["ejs"],
|
||||
Elixir: ["ex|exs"],
|
||||
Elm: ["elm"],
|
||||
Erlang: ["erl|hrl"],
|
||||
EJS: ["ejs"],
|
||||
Forth: ["frt|fs|ldr"],
|
||||
FTL: ["ftl"],
|
||||
Gcode: ["gcode"],
|
||||
Gherkin: ["feature"],
|
||||
Gitignore: ["^.gitignore"],
|
||||
Glsl: ["glsl|frag|vert"],
|
||||
|
|
@ -88,7 +82,6 @@ var supportedModes = {
|
|||
HTML: ["html|htm|xhtml"],
|
||||
HTML_Ruby: ["erb|rhtml|html.erb"],
|
||||
INI: ["ini|conf|cfg|prefs"],
|
||||
Io: ["io"],
|
||||
Jack: ["jack"],
|
||||
Jade: ["jade"],
|
||||
Java: ["java"],
|
||||
|
|
@ -99,7 +92,6 @@ var supportedModes = {
|
|||
JSX: ["jsx"],
|
||||
Julia: ["jl"],
|
||||
LaTeX: ["tex|latex|ltx|bib"],
|
||||
Lean: ["lean|hlean"],
|
||||
LESS: ["less"],
|
||||
Liquid: ["liquid"],
|
||||
Lisp: ["lisp"],
|
||||
|
|
@ -110,20 +102,18 @@ var supportedModes = {
|
|||
LuaPage: ["lp"],
|
||||
Lucene: ["lucene"],
|
||||
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
|
||||
Markdown: ["md|markdown"],
|
||||
Mask: ["mask"],
|
||||
MATLAB: ["matlab"],
|
||||
Markdown: ["md|markdown"],
|
||||
MEL: ["mel"],
|
||||
MUSHCode: ["mc|mush"],
|
||||
MySQL: ["mysql"],
|
||||
MUSHCode: ["mc|mush"],
|
||||
Nix: ["nix"],
|
||||
Nim: ["nim"],
|
||||
ObjectiveC: ["m|mm"],
|
||||
OCaml: ["ml|mli"],
|
||||
Pascal: ["pas|p"],
|
||||
Perl: ["pl|pm"],
|
||||
pgSQL: ["pgsql"],
|
||||
PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"],
|
||||
PHP: ["php|phtml"],
|
||||
Powershell: ["ps1"],
|
||||
Praat: ["praat|praatscript|psc|proc"],
|
||||
Prolog: ["plg|prolog"],
|
||||
|
|
@ -138,16 +128,15 @@ var supportedModes = {
|
|||
SASS: ["sass"],
|
||||
SCAD: ["scad"],
|
||||
Scala: ["scala"],
|
||||
Smarty: ["smarty|tpl"],
|
||||
Scheme: ["scm|rkt"],
|
||||
SCSS: ["scss"],
|
||||
SH: ["sh|bash|^.bashrc"],
|
||||
SJS: ["sjs"],
|
||||
Smarty: ["smarty|tpl"],
|
||||
Space: ["space"],
|
||||
snippets: ["snippets"],
|
||||
Soy_Template:["soy"],
|
||||
Space: ["space"],
|
||||
SQL: ["sql"],
|
||||
SQLServer: ["sqlserver"],
|
||||
Stylus: ["styl|stylus"],
|
||||
SVG: ["svg"],
|
||||
Tcl: ["tcl"],
|
||||
|
|
@ -158,22 +147,19 @@ var supportedModes = {
|
|||
Twig: ["twig"],
|
||||
Typescript: ["ts|typescript|str"],
|
||||
Vala: ["vala"],
|
||||
VBScript: ["vbs|vb"],
|
||||
VBScript: ["vbs"],
|
||||
Velocity: ["vm"],
|
||||
Verilog: ["v|vh|sv|svh"],
|
||||
VHDL: ["vhd|vhdl"],
|
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
|
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
|
||||
XQuery: ["xq"],
|
||||
YAML: ["yaml|yml"],
|
||||
// Add the missing mode "Django" to ext-modelist
|
||||
Django: ["html"]
|
||||
YAML: ["yaml|yml"]
|
||||
};
|
||||
|
||||
var nameOverrides = {
|
||||
ObjectiveC: "Objective-C",
|
||||
CSharp: "C#",
|
||||
golang: "Go",
|
||||
C_Cpp: "C and C++",
|
||||
C_Cpp: "C/C++",
|
||||
coffee: "CoffeeScript",
|
||||
HTML_Ruby: "HTML (Ruby)",
|
||||
FTL: "FreeMarker"
|
||||
|
|
@ -195,3 +181,4 @@ module.exports = {
|
|||
};
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
background-color: #ddd;
|
||||
border: 1px solid #cbcbcb;
|
||||
border-top: 0 none;
|
||||
max-width: 325px;
|
||||
max-width: 297px;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
padding: 4px;
|
||||
|
|
@ -47,6 +47,7 @@
|
|||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
float: left;
|
||||
height: 22px;
|
||||
outline: 0;
|
||||
|
|
@ -60,6 +61,7 @@
|
|||
border: 0 none;
|
||||
border-left: 1px solid #dcdcdc;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
float: left;
|
||||
height: 22px;
|
||||
margin: 0;
|
||||
|
|
@ -92,9 +94,12 @@
|
|||
border: 0 none;
|
||||
color: #656565;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
float: right;
|
||||
font: 16px/16px Arial;
|
||||
font-family: Arial;
|
||||
font-size: 16px;
|
||||
height: 14px;
|
||||
line-height: 16px;
|
||||
margin: 5px 1px 9px 5px;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ var html = '<div class="ace_search right">\
|
|||
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
|
||||
<button type="button" action="findNext" class="ace_searchbtn next"></button>\
|
||||
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\
|
||||
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\
|
||||
</div>\
|
||||
<div class="ace_replace_form">\
|
||||
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
|
||||
|
|
@ -171,11 +170,6 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
sb.replace();
|
||||
sb.findPrev();
|
||||
},
|
||||
"Alt-Return": function(sb) {
|
||||
if (sb.activeInput == sb.replaceInput)
|
||||
sb.replaceAll();
|
||||
sb.findAll();
|
||||
},
|
||||
"Tab": function(sb) {
|
||||
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
||||
}
|
||||
|
|
@ -235,18 +229,6 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
this.findPrev = function() {
|
||||
this.find(true, true);
|
||||
};
|
||||
this.findAll = function(){
|
||||
var range = this.editor.findAll(this.searchInput.value, {
|
||||
regExp: this.regExpOption.checked,
|
||||
caseSensitive: this.caseSensitiveOption.checked,
|
||||
wholeWord: this.wholeWordOption.checked
|
||||
});
|
||||
var noMatch = !range && this.searchInput.value;
|
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
||||
this.editor._emit("findSearchBox", { match: !noMatch });
|
||||
this.highlight();
|
||||
this.hide();
|
||||
};
|
||||
this.replace = function() {
|
||||
if (!this.editor.getReadOnly())
|
||||
this.editor.replace(this.replaceInput.value);
|
||||
|
|
@ -281,10 +263,6 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
|
||||
};
|
||||
|
||||
this.isFocused = function() {
|
||||
var el = document.activeElement;
|
||||
return el == this.searchInput || el == this.replaceInput;
|
||||
}
|
||||
}).call(SearchBox.prototype);
|
||||
|
||||
exports.SearchBox = SearchBox;
|
||||
|
|
|
|||
|
|
@ -1,31 +1,25 @@
|
|||
.ace_static_highlight {
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;
|
||||
font-size: 12px;
|
||||
white-space: pre-wrap
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.ace_static_highlight .ace_gutter {
|
||||
width: 2em;
|
||||
width: 25px !important;
|
||||
display: block;
|
||||
float: left;
|
||||
text-align: right;
|
||||
padding: 0 3px 0 0;
|
||||
margin-right: 3px;
|
||||
position: static !important;
|
||||
}
|
||||
|
||||
.ace_static_highlight.ace_show_gutter .ace_line {
|
||||
padding-left: 2.6em;
|
||||
}
|
||||
|
||||
.ace_static_highlight .ace_line { position: relative; }
|
||||
.ace_static_highlight .ace_line { clear: both; }
|
||||
|
||||
.ace_static_highlight .ace_gutter-cell {
|
||||
-moz-user-select: -moz-none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
-moz-user-select: -moz-none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@ var baseStyles = require("../requirejs/text!./static.css");
|
|||
var config = require("../config");
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
var SimpleTextLayer = function() {
|
||||
this.config = {};
|
||||
};
|
||||
SimpleTextLayer.prototype = TextLayer.prototype;
|
||||
|
||||
var highlight = function(el, opts, callback) {
|
||||
var m = el.className.match(/lang-(\w+)/);
|
||||
|
|
@ -102,6 +98,7 @@ var highlight = function(el, opts, callback) {
|
|||
* and `css`.
|
||||
* @returns {object} An object containing the properties `html` and `css`.
|
||||
*/
|
||||
|
||||
highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) {
|
||||
var waiting = 1;
|
||||
var modeCache = EditSession.prototype.$modes;
|
||||
|
|
@ -115,17 +112,11 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
|
|||
--waiting || done();
|
||||
});
|
||||
}
|
||||
// allow setting mode options e.h {path: "ace/mode/php", inline:true}
|
||||
var modeOptions;
|
||||
if (mode && typeof mode === "object" && !mode.getTokenizer) {
|
||||
modeOptions = mode;
|
||||
mode = modeOptions.path;
|
||||
}
|
||||
|
||||
if (typeof mode == "string") {
|
||||
waiting++;
|
||||
config.loadModule(['mode', mode], function(m) {
|
||||
if (!modeCache[mode] || modeOptions)
|
||||
modeCache[mode] = new m.Mode(modeOptions);
|
||||
if (!modeCache[mode]) modeCache[mode] = new m.Mode();
|
||||
mode = modeCache[mode];
|
||||
--waiting || done();
|
||||
});
|
||||
|
|
@ -139,13 +130,14 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
|
|||
return --waiting || done();
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Transforms a given input code snippet into HTML using the given mode
|
||||
* @param {string} input Code snippet
|
||||
* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')
|
||||
* @param {string} r Code snippet
|
||||
* @returns {object} An object containing: html, css
|
||||
*/
|
||||
|
||||
highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
|
||||
lineStart = parseInt(lineStart || 1, 10);
|
||||
|
||||
|
|
@ -153,8 +145,12 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
|
|||
session.setUseWorker(false);
|
||||
session.setMode(mode);
|
||||
|
||||
var textLayer = new SimpleTextLayer();
|
||||
var textLayer = new TextLayer(document.createElement("div"));
|
||||
textLayer.setSession(session);
|
||||
textLayer.config = {
|
||||
characterWidth: 10,
|
||||
lineHeight: 20
|
||||
};
|
||||
|
||||
session.setValue(input);
|
||||
|
||||
|
|
@ -171,8 +167,7 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
|
|||
|
||||
// let's prepare the whole html
|
||||
var html = "<div class='" + theme.cssClass + "'>" +
|
||||
"<div class='ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter") +
|
||||
"' style='counter-reset:ace_line " + (lineStart - 1) + "'>" +
|
||||
"<div class='ace_static_highlight' style='counter-reset:ace_line " + (lineStart - 1) + "'>" +
|
||||
stringBuilder.join("") +
|
||||
"</div>" +
|
||||
"</div>";
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ module.exports = {
|
|||
var mode = new JavaScriptMode();
|
||||
|
||||
var result = highlighter.render(snippet, mode, theme);
|
||||
assert.equal(result.html, "<div class='ace-tomorrow'><div class='ace_static_highlight ace_show_gutter' style='counter-reset:ace_line 0'>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>/** this is a function</span>\n</div>"
|
||||
assert.equal(result.html, "<div class='ace-tomorrow'><div class='ace_static_highlight' style='counter-reset:ace_line 0'>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>/**\xa0this\xa0is\xa0a\xa0function</span>\n</div>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>*</span>\n</div>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>*/</span>\n</div>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_storage ace_type'>function</span> <span class='ace_entity ace_name ace_function'>hello</span> <span class='ace_paren ace_lparen'>(</span><span class='ace_variable ace_parameter'>a</span><span class='ace_punctuation ace_operator'>, </span><span class='ace_variable ace_parameter'>b</span><span class='ace_punctuation ace_operator'>, </span><span class='ace_variable ace_parameter'>c</span><span class='ace_paren ace_rparen'>)</span> <span class='ace_paren ace_lparen'>{</span>\n</div>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span> <span class='ace_storage ace_type'>console</span><span class='ace_punctuation ace_operator'>.</span><span class='ace_support ace_function ace_firebug'>log</span><span class='ace_paren ace_lparen'>(</span><span class='ace_identifier'>a</span> <span class='ace_keyword ace_operator'>*</span> <span class='ace_identifier'>b</span> <span class='ace_keyword ace_operator'>+</span> <span class='ace_identifier'>c</span> <span class='ace_keyword ace_operator'>+</span> <span class='ace_string'>'sup$'</span><span class='ace_paren ace_rparen'>)</span><span class='ace_punctuation ace_operator'>;</span>\n</div>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_storage ace_type'>function</span>\xa0<span class='ace_entity ace_name ace_function'>hello</span>\xa0<span class='ace_paren ace_lparen'>(</span><span class='ace_variable ace_parameter'>a</span><span class='ace_punctuation ace_operator'>,\xa0</span><span class='ace_variable ace_parameter'>b</span><span class='ace_punctuation ace_operator'>,\xa0</span><span class='ace_variable ace_parameter'>c</span><span class='ace_paren ace_rparen'>)</span>\xa0<span class='ace_paren ace_lparen'>{</span>\n</div>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span>\xa0\xa0\xa0\xa0<span class='ace_storage ace_type'>console</span><span class='ace_punctuation ace_operator'>.</span><span class='ace_support ace_function ace_firebug'>log</span><span class='ace_paren ace_lparen'>(</span><span class='ace_identifier'>a</span>\xa0<span class='ace_keyword ace_operator'>*</span>\xa0<span class='ace_identifier'>b</span>\xa0<span class='ace_keyword ace_operator'>+</span>\xa0<span class='ace_identifier'>c</span>\xa0<span class='ace_keyword ace_operator'>+</span>\xa0<span class='ace_string'>'sup$'</span><span class='ace_paren ace_rparen'>)</span><span class='ace_punctuation ace_operator'>;</span>\n</div>"
|
||||
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_paren ace_rparen'>}</span>\n</div>"
|
||||
+ "</div></div>");
|
||||
assert.ok(!!result.css);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ var StatusBar = function(editor, parentNode) {
|
|||
str && status.push(str, separator || "|");
|
||||
}
|
||||
|
||||
add(editor.keyBinding.getStatusText(editor));
|
||||
if (editor.commands.recording)
|
||||
if (editor.$vimModeHandler)
|
||||
add(editor.$vimModeHandler.getStatusText());
|
||||
else if (editor.commands.recording)
|
||||
add("REC");
|
||||
|
||||
var c = editor.selection.lead;
|
||||
|
|
|
|||
|
|
@ -51,14 +51,12 @@ var themeData = [
|
|||
["Dreamweaver" ],
|
||||
["Eclipse" ],
|
||||
["GitHub" ],
|
||||
["IPlastic" ],
|
||||
["Solarized Light"],
|
||||
["TextMate" ],
|
||||
["Tomorrow" ],
|
||||
["XCode" ],
|
||||
["Kuroir"],
|
||||
["KatzenMilch"],
|
||||
["SQL Server" ,"sqlserver" , "light"],
|
||||
["Ambiance" ,"ambiance" , "dark"],
|
||||
["Chaos" ,"chaos" , "dark"],
|
||||
["Clouds Midnight" ,"clouds_midnight" , "dark"],
|
||||
|
|
@ -73,7 +71,6 @@ var themeData = [
|
|||
["Solarized Dark" ,"solarized_dark" , "dark"],
|
||||
["Terminal" ,"terminal" , "dark"],
|
||||
["Tomorrow Night" ,"tomorrow_night" , "dark"],
|
||||
["The Night After Tomorrow" ,"the_night_after_tomorrow" , "dark"],
|
||||
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
|
||||
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
|
||||
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
|
||||
|
|
|
|||
|
|
@ -76,14 +76,11 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
var first = {score: 0, length: 0};
|
||||
var spaceIndents = 0;
|
||||
for (var i = 1; i < 12; i++) {
|
||||
var score = getScore(i);
|
||||
if (i == 1) {
|
||||
spaceIndents = score;
|
||||
score = stats[1] ? 0.9 : 0.8;
|
||||
if (!stats.length)
|
||||
score = 0
|
||||
spaceIndents = getScore(i);
|
||||
var score = stats.length && 1;
|
||||
} else
|
||||
score /= spaceIndents;
|
||||
var score = getScore(i) / spaceIndents;
|
||||
|
||||
if (changes[i])
|
||||
score += changes[i] / changesTotal;
|
||||
|
|
|
|||
|
|
@ -64,34 +64,6 @@ function IncrementalSearch() {
|
|||
|
||||
oop.inherits(IncrementalSearch, Search);
|
||||
|
||||
// regexp handling
|
||||
|
||||
function isRegExp(obj) {
|
||||
return obj instanceof RegExp;
|
||||
}
|
||||
|
||||
function regExpToObject(re) {
|
||||
var string = String(re),
|
||||
start = string.indexOf('/'),
|
||||
flagStart = string.lastIndexOf('/');
|
||||
return {
|
||||
expression: string.slice(start+1, flagStart),
|
||||
flags: string.slice(flagStart+1)
|
||||
}
|
||||
}
|
||||
|
||||
function stringToRegExp(string, flags) {
|
||||
try {
|
||||
return new RegExp(string, flags);
|
||||
} catch (e) { return string; }
|
||||
}
|
||||
|
||||
function objectToRegExp(obj) {
|
||||
return stringToRegExp(obj.expression, obj.flags);
|
||||
}
|
||||
|
||||
// iSearch class
|
||||
|
||||
;(function() {
|
||||
|
||||
this.activate = function(ed, backwards) {
|
||||
|
|
@ -105,7 +77,7 @@ function objectToRegExp(obj) {
|
|||
this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
|
||||
this.selectionFix(ed);
|
||||
this.statusMessage(true);
|
||||
};
|
||||
}
|
||||
|
||||
this.deactivate = function(reset) {
|
||||
this.cancelSearch(reset);
|
||||
|
|
@ -117,7 +89,7 @@ function objectToRegExp(obj) {
|
|||
}
|
||||
ed.onPaste = this.$originalEditorOnPaste;
|
||||
this.message('');
|
||||
};
|
||||
}
|
||||
|
||||
this.selectionFix = function(editor) {
|
||||
// Fix selection bug: When clicked inside the editor
|
||||
|
|
@ -128,7 +100,7 @@ function objectToRegExp(obj) {
|
|||
if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
|
||||
editor.clearSelection();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.highlight = function(regexp) {
|
||||
var sess = this.$editor.session,
|
||||
|
|
@ -136,7 +108,7 @@ function objectToRegExp(obj) {
|
|||
new SearchHighlight(null, "ace_isearch-result", "text"));
|
||||
hl.setRegexp(regexp);
|
||||
sess._emit("changeBackMarker"); // force highlight layer redraw
|
||||
};
|
||||
}
|
||||
|
||||
this.cancelSearch = function(reset) {
|
||||
var e = this.$editor;
|
||||
|
|
@ -150,7 +122,7 @@ function objectToRegExp(obj) {
|
|||
}
|
||||
this.highlight(null);
|
||||
return Range.fromPoints(this.$currentPos, this.$currentPos);
|
||||
};
|
||||
}
|
||||
|
||||
this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
|
||||
if (!this.$editor) return null;
|
||||
|
|
@ -163,46 +135,36 @@ function objectToRegExp(obj) {
|
|||
if (options.needle.length === 0) {
|
||||
this.statusMessage(true);
|
||||
return this.cancelSearch(true);
|
||||
}
|
||||
};
|
||||
|
||||
// try to find the next occurence and enable highlighting marker
|
||||
options.start = this.$currentPos;
|
||||
var session = this.$editor.session,
|
||||
found = this.find(session),
|
||||
shouldSelect = this.$editor.emacsMark ?
|
||||
!!this.$editor.emacsMark() : !this.$editor.selection.isEmpty();
|
||||
found = this.find(session);
|
||||
if (found) {
|
||||
if (options.backwards) found = Range.fromPoints(found.end, found.start);
|
||||
this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
|
||||
this.$editor.moveCursorToPosition(found.end);
|
||||
if (moveToNext) this.$currentPos = found.end;
|
||||
// highlight after cursor move, so selection works properly
|
||||
this.highlight(options.re);
|
||||
this.highlight(options.re)
|
||||
}
|
||||
|
||||
this.statusMessage(found);
|
||||
|
||||
return found;
|
||||
};
|
||||
}
|
||||
|
||||
this.addString = function(s) {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
if (!isRegExp(needle))
|
||||
return needle + s;
|
||||
var reObj = regExpToObject(needle);
|
||||
reObj.expression += s;
|
||||
return objectToRegExp(reObj);
|
||||
return needle + s;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.removeChar = function(c) {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
if (!isRegExp(needle))
|
||||
return needle.substring(0, needle.length-1);
|
||||
var reObj = regExpToObject(needle);
|
||||
reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
|
||||
return objectToRegExp(reObj);
|
||||
return needle.length > 0 ? needle.substring(0, needle.length-1) : needle;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.next = function(options) {
|
||||
// try to find the next occurence of whatever we have searched for
|
||||
|
|
@ -215,29 +177,17 @@ function objectToRegExp(obj) {
|
|||
return options.useCurrentOrPrevSearch && needle.length === 0 ?
|
||||
this.$prevNeedle || '' : needle;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.onMouseDown = function(evt) {
|
||||
// when mouse interaction happens then we quit incremental search
|
||||
this.deactivate();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
this.onPaste = function(text) {
|
||||
this.addString(text);
|
||||
};
|
||||
|
||||
this.convertNeedleToRegExp = function() {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
|
||||
});
|
||||
};
|
||||
|
||||
this.convertNeedleToString = function() {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
return isRegExp(needle) ? regExpToObject(needle).expression : needle;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.statusMessage = function(found) {
|
||||
var options = this.$options, msg = '';
|
||||
|
|
@ -245,7 +195,7 @@ function objectToRegExp(obj) {
|
|||
msg += 'isearch: ' + options.needle;
|
||||
msg += found ? '' : ' (not found)';
|
||||
this.message(msg);
|
||||
};
|
||||
}
|
||||
|
||||
this.message = function(msg) {
|
||||
if (this.$editor.showCommandLine) {
|
||||
|
|
@ -254,7 +204,7 @@ function objectToRegExp(obj) {
|
|||
} else {
|
||||
console.log(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}).call(IncrementalSearch.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,17 +35,13 @@ if (typeof process !== "undefined") {
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var emacs = require('./keyboard/emacs');
|
||||
var EditSession = require("./edit_session").EditSession;
|
||||
var Editor = require("./editor").Editor;
|
||||
var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||
var Range = require("./range").Range;
|
||||
var MultiSelect = require("./multi_select").MultiSelect;
|
||||
var assert = require("./test/assertions");
|
||||
var IncrementalSearch = require("./incremental_search").IncrementalSearch;
|
||||
|
||||
require("./multi_select");
|
||||
|
||||
var editor, iSearch;
|
||||
function testRanges(str, ranges) {
|
||||
ranges = ranges || editor.selection.getAllRanges();
|
||||
|
|
@ -73,7 +69,6 @@ module.exports = {
|
|||
setUp: function() {
|
||||
var session = new EditSession(["abc123", "xyz124"]);
|
||||
editor = new Editor(new MockRenderer(), session);
|
||||
new MultiSelect(editor);
|
||||
iSearch = new IncrementalSearch();
|
||||
},
|
||||
|
||||
|
|
@ -200,7 +195,7 @@ module.exports = {
|
|||
editor.keyBinding.addKeyboardHandler(emacs.handler);
|
||||
emacs.handler.commands.setMark.exec(editor);
|
||||
iSearch.activate(editor);
|
||||
iSearch.addString('1'); iSearch.addString('2');
|
||||
iSearch.addString('1'); iSearch.addString('2');;
|
||||
testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()], "sel range");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ exports.handler.attach = function(editor) {
|
|||
initialized = true;
|
||||
dom.importCssString('\
|
||||
.emacs-mode .ace_cursor{\
|
||||
border: 1px rgba(50,250,50,0.8) solid!important;\
|
||||
border: 2px rgba(50,250,50,0.8) solid!important;\
|
||||
-moz-box-sizing: border-box!important;\
|
||||
-webkit-box-sizing: border-box!important;\
|
||||
box-sizing: border-box!important;\
|
||||
|
|
@ -125,24 +125,6 @@ exports.handler.attach = function(editor) {
|
|||
return this.session.$emacsMark || this.session.$emacsMarkRing.slice(-1)[0];
|
||||
};
|
||||
|
||||
editor.emacsMarkForSelection = function(replacement) {
|
||||
// find the mark in $emacsMarkRing corresponding to the current
|
||||
// selection
|
||||
var sel = this.selection,
|
||||
multiRangeLength = this.multiSelect ?
|
||||
this.multiSelect.getAllRanges().length : 1,
|
||||
selIndex = sel.index || 0,
|
||||
markRing = this.session.$emacsMarkRing,
|
||||
markIndex = markRing.length - (multiRangeLength - selIndex),
|
||||
lastMark = markRing[markIndex] || sel.anchor;
|
||||
if (replacement) {
|
||||
markRing.splice(markIndex, 1,
|
||||
"row" in replacement && "column" in replacement ?
|
||||
replacement : undefined);
|
||||
}
|
||||
return lastMark;
|
||||
}
|
||||
|
||||
editor.on("click", $resetMarkMode);
|
||||
editor.on("changeSession", $kbSessionChange);
|
||||
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
|
||||
|
|
@ -164,7 +146,6 @@ exports.handler.detach = function(editor) {
|
|||
editor.commands.removeCommands(commands);
|
||||
editor.removeEventListener('copy', this.onCopy);
|
||||
editor.removeEventListener('paste', this.onPaste);
|
||||
editor.$emacsModeHandler = null;
|
||||
};
|
||||
|
||||
var $kbSessionChange = function(e) {
|
||||
|
|
@ -206,7 +187,7 @@ exports.handler.onCopy = function(e, editor) {
|
|||
if (editor.$handlesEmacsOnCopy) return;
|
||||
editor.$handlesEmacsOnCopy = true;
|
||||
exports.handler.commands.killRingSave.exec(editor);
|
||||
editor.$handlesEmacsOnCopy = false;
|
||||
delete editor.$handlesEmacsOnCopy;
|
||||
};
|
||||
|
||||
exports.handler.onPaste = function(e, editor) {
|
||||
|
|
@ -214,8 +195,6 @@ exports.handler.onPaste = function(e, editor) {
|
|||
};
|
||||
|
||||
exports.handler.bindKey = function(key, command) {
|
||||
if (typeof key == "object")
|
||||
key = key[this.platform];
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
|
|
@ -239,22 +218,12 @@ exports.handler.bindKey = function(key, command) {
|
|||
}, this);
|
||||
};
|
||||
|
||||
exports.handler.getStatusText = function(editor, data) {
|
||||
var str = "";
|
||||
if (data.count)
|
||||
str += data.count;
|
||||
if (data.keyChain)
|
||||
str += " " + data.keyChain
|
||||
return str;
|
||||
};
|
||||
|
||||
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||
// if keyCode == -1 a non-printable key was pressed, such as just
|
||||
// control. Handling those is currently not supported in this handler
|
||||
if (keyCode === -1) return undefined;
|
||||
|
||||
var editor = data.editor;
|
||||
editor._signal("changeStatus");
|
||||
// insertstring data.count times
|
||||
if (hashId == -1) {
|
||||
editor.pushEmacsMark();
|
||||
|
|
@ -265,17 +234,24 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|||
}
|
||||
}
|
||||
|
||||
if (key == "\x00") return undefined;
|
||||
|
||||
var modifier = eMods[hashId];
|
||||
|
||||
// CTRL + number / universalArgument for setting data.count
|
||||
if (modifier == "c-" || data.count) {
|
||||
if (modifier == "c-" || data.universalArgument) {
|
||||
var prevCount = String(data.count || 0);
|
||||
var count = parseInt(key[key.length - 1]);
|
||||
if (typeof count === 'number' && !isNaN(count)) {
|
||||
data.count = Math.max(data.count, 0) || 0;
|
||||
data.count = 10 * data.count + count;
|
||||
data.count = parseInt(prevCount + count);
|
||||
return {command: "null"};
|
||||
} else if (data.universalArgument) {
|
||||
// if no number pressed use emacs defaults for universalArgument
|
||||
// which is 4
|
||||
data.count = 4;
|
||||
}
|
||||
}
|
||||
data.universalArgument = false;
|
||||
|
||||
// this.commandKeyBinding maps key specs like "c-p" (for CTRL + P) to
|
||||
// command objects, for lookup key needs to include the modifier
|
||||
|
|
@ -297,9 +273,7 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|||
if (command === "null") return {command: "null"};
|
||||
|
||||
if (command === "universalArgument") {
|
||||
// if no number pressed emacs repeats action 4 times.
|
||||
// minus sign is needed to allow next keypress to replace it
|
||||
data.count = -4;
|
||||
data.universalArgument = true;
|
||||
return {command: "null"};
|
||||
}
|
||||
|
||||
|
|
@ -326,12 +300,9 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|||
if (!command) return undefined;
|
||||
}
|
||||
|
||||
if (!command.readOnly && !command.isYank)
|
||||
if (!command.readonly && !command.isYank)
|
||||
data.lastCommand = null;
|
||||
|
||||
if (!command.readOnly && editor.emacsMark())
|
||||
editor.setEmacsMark(null)
|
||||
|
||||
if (data.count) {
|
||||
var count = data.count;
|
||||
data.count = 0;
|
||||
|
|
@ -342,8 +313,7 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|||
exec: function(editor, args) {
|
||||
for (var i = 0; i < count; i++)
|
||||
command.exec(editor, args);
|
||||
},
|
||||
multiSelectAction: command.multiSelectAction
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
|
@ -414,7 +384,7 @@ exports.emacsKeys = {
|
|||
"M-y": "yankRotate",
|
||||
"C-g": "keyboardQuit",
|
||||
|
||||
"C-w|C-S-W": "killRegion",
|
||||
"C-w": "killRegion",
|
||||
"M-w": "killRingSave",
|
||||
"C-Space": "setMark",
|
||||
"C-x C-x": "exchangePointAndMark",
|
||||
|
|
@ -428,7 +398,7 @@ exports.emacsKeys = {
|
|||
"M-;": "togglecomment",
|
||||
|
||||
"C-/|C-x u|S-C--|C-z": "undo",
|
||||
"S-C-/|S-C-x u|C--|S-C-z": "redo", // infinite undo?
|
||||
"S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo?
|
||||
// vertical editing
|
||||
"C-x r": "selectRectangularRegion",
|
||||
"M-x": {command: "focusCommandLine", args: "M-x "}
|
||||
|
|
@ -464,65 +434,61 @@ exports.handler.addCommands({
|
|||
// selection modification commands. That is,
|
||||
// "goto" commands become "select" commands.
|
||||
// Any insertion or mouse click resets mark-mode.
|
||||
// setMark twice in a row at the same place resets markmode.
|
||||
// in multi select mode, ea selection is handled individually
|
||||
|
||||
// setMark twice in a row at the same place resets markmode
|
||||
if (args && args.count) {
|
||||
if (editor.inMultiSelectMode) editor.forEachSelection(moveToMark);
|
||||
else moveToMark();
|
||||
moveToMark();
|
||||
var mark = editor.popEmacsMark();
|
||||
mark && editor.selection.moveCursorToPosition(mark);
|
||||
return;
|
||||
}
|
||||
|
||||
var mark = editor.emacsMark(),
|
||||
ranges = editor.selection.getAllRanges(),
|
||||
rangePositions = ranges.map(function(r) { return {row: r.start.row, column: r.start.column}; }),
|
||||
transientMarkModeActive = true,
|
||||
hasNoSelection = ranges.every(function(range) { return range.isEmpty(); });
|
||||
transientMarkModeActive = true;
|
||||
|
||||
// if transientMarkModeActive then mark behavior is a little
|
||||
// different. Deactivate the mark when setMark is run with active
|
||||
// mark
|
||||
if (transientMarkModeActive && (mark || !hasNoSelection)) {
|
||||
if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)});
|
||||
else editor.clearSelection();
|
||||
if (mark) editor.pushEmacsMark(null);
|
||||
if (transientMarkModeActive && (mark || !editor.selection.isEmpty())) {
|
||||
editor.pushEmacsMark();
|
||||
editor.clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mark) {
|
||||
rangePositions.forEach(function(pos) { editor.pushEmacsMark(pos); });
|
||||
editor.setEmacsMark(rangePositions[rangePositions.length-1]);
|
||||
return;
|
||||
if (mark) {
|
||||
var cp = editor.getCursorPosition();
|
||||
if (editor.selection.isEmpty() &&
|
||||
mark.row == cp.row && mark.column == cp.column) {
|
||||
editor.pushEmacsMark();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
function moveToMark() {
|
||||
var mark = editor.popEmacsMark();
|
||||
mark && editor.moveCursorToPosition(mark);
|
||||
}
|
||||
|
||||
// turn on mark mode
|
||||
mark = editor.getCursorPosition();
|
||||
editor.setEmacsMark(mark);
|
||||
editor.selection.setSelectionAnchor(mark.row, mark.column);
|
||||
},
|
||||
readOnly: true,
|
||||
handlesCount: true
|
||||
readonly: true,
|
||||
handlesCount: true,
|
||||
multiSelectAction: "forEach"
|
||||
},
|
||||
exchangePointAndMark: {
|
||||
exec: function exchangePointAndMark$exec(editor, args) {
|
||||
exec: function(editor, args) {
|
||||
var sel = editor.selection;
|
||||
if (!args.count && !sel.isEmpty()) { // just invert selection
|
||||
sel.setSelectionRange(sel.getRange(), !sel.isBackwards());
|
||||
if (args.count) {
|
||||
var pos = editor.getCursorPosition();
|
||||
sel.clearSelection();
|
||||
sel.moveCursorToPosition(editor.popEmacsMark());
|
||||
editor.pushEmacsMark(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.count) { // replace mark and point
|
||||
var pos = {row: sel.lead.row, column: sel.lead.column};
|
||||
sel.clearSelection();
|
||||
sel.moveCursorToPosition(editor.emacsMarkForSelection(pos));
|
||||
} else { // create selection to last mark
|
||||
sel.selectToPosition(editor.emacsMarkForSelection());
|
||||
var lastMark = editor.getLastEmacsMark();
|
||||
var range = sel.getRange();
|
||||
if (range.isEmpty()) {
|
||||
sel.selectToPosition(lastMark);
|
||||
return;
|
||||
}
|
||||
sel.setSelectionRange(range, !sel.isBackwards());
|
||||
},
|
||||
readOnly: true,
|
||||
readonly: true,
|
||||
handlesCount: true,
|
||||
multiSelectAction: "forEach"
|
||||
},
|
||||
|
|
@ -573,7 +539,6 @@ exports.handler.addCommands({
|
|||
if (editor.keyBinding.$data.lastCommand != "yank")
|
||||
return;
|
||||
editor.undo();
|
||||
editor.session.$emacsMarkRing.pop(); // also undo recording mark
|
||||
editor.onPaste(exports.killRing.rotate());
|
||||
editor.keyBinding.$data.lastCommand = "yank";
|
||||
},
|
||||
|
|
@ -582,38 +547,24 @@ exports.handler.addCommands({
|
|||
exports.killRing.add(editor.getCopyText());
|
||||
editor.commands.byName.cut.exec(editor);
|
||||
},
|
||||
readOnly: true,
|
||||
readonly: true,
|
||||
multiSelectAction: "forEach"
|
||||
},
|
||||
killRingSave: {
|
||||
exec: function(editor) {
|
||||
// copy text and deselect. will save marks for starts of the
|
||||
// selection(s)
|
||||
|
||||
editor.$handlesEmacsOnCopy = true;
|
||||
var marks = editor.session.$emacsMarkRing.slice(),
|
||||
deselectedMarks = [];
|
||||
exports.killRing.add(editor.getCopyText());
|
||||
|
||||
setTimeout(function() {
|
||||
function deselect() {
|
||||
var sel = editor.selection, range = sel.getRange(),
|
||||
pos = sel.isBackwards() ? range.end : range.start;
|
||||
deselectedMarks.push({row: pos.row, column: pos.column});
|
||||
sel.clearSelection();
|
||||
}
|
||||
editor.$handlesEmacsOnCopy = false;
|
||||
if (editor.inMultiSelectMode) editor.forEachSelection({exec: deselect});
|
||||
else deselect();
|
||||
editor.session.$emacsMarkRing = marks.concat(deselectedMarks.reverse());
|
||||
var sel = editor.selection,
|
||||
range = sel.getRange();
|
||||
editor.pushEmacsMark(sel.isBackwards() ? range.end : range.start);
|
||||
sel.clearSelection();
|
||||
}, 0);
|
||||
},
|
||||
readOnly: true
|
||||
readonly: true
|
||||
},
|
||||
keyboardQuit: function(editor) {
|
||||
editor.selection.clearSelection();
|
||||
editor.setEmacsMark(null);
|
||||
editor.keyBinding.$data.count = null;
|
||||
},
|
||||
focusCommandLine: function(editor, arg) {
|
||||
if (editor.showCommandLine)
|
||||
|
|
|
|||
|
|
@ -35,29 +35,17 @@ if (typeof process !== "undefined") {
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
require("../multi_select");
|
||||
|
||||
var EditSession = require("./../edit_session").EditSession,
|
||||
Editor = require("./../editor").Editor,
|
||||
Range = require("./../range").Range,
|
||||
MockRenderer = require("./../test/mockrenderer").MockRenderer,
|
||||
emacs = require('./emacs'),
|
||||
assert = require("./../test/assertions"),
|
||||
editor, sel;
|
||||
editor;
|
||||
|
||||
function initEditor(docString) {
|
||||
var doc = new EditSession(docString.split("\n"));
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
editor.setKeyboardHandler(emacs.handler);
|
||||
sel = editor.selection;
|
||||
}
|
||||
|
||||
function print(obj) {
|
||||
return JSON.stringify(obj, null, 2);
|
||||
}
|
||||
|
||||
function pluck(arr, what) {
|
||||
return arr.map(function(ea) { return ea[what]; });
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -74,72 +62,6 @@ module.exports = {
|
|||
editor.selectAll();
|
||||
editor.execCommand('keyboardQuit');
|
||||
assert.ok(editor.selection.isEmpty(), 'selection non-empty');
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark without mark set": function() {
|
||||
initEditor('foo');
|
||||
sel.setRange(Range.fromPoints({row: 0, column: 1}, {row: 0, column: 3}));
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition()));
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with mark set": function() {
|
||||
initEditor('foo');
|
||||
editor.pushEmacsMark({row: 0, column: 1});
|
||||
editor.pushEmacsMark({row: 0, column: 2});
|
||||
editor.execCommand('exchangePointAndMark', {count: 4});
|
||||
assert.deepEqual({row: 0, column: 2}, editor.getCursorPosition(), print(editor.getCursorPosition()));
|
||||
assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 0}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with selection": function() {
|
||||
initEditor('foo');
|
||||
editor.pushEmacsMark({row: 0, column: 1});
|
||||
editor.pushEmacsMark({row: 0, column: 2});
|
||||
sel.setRange(Range.fromPoints({row: 0, column: 0}, {row: 0, column: 1}), true);
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition()));
|
||||
assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 2}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with multi selection": function() {
|
||||
initEditor('foo\nhello world\n123');
|
||||
var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}],
|
||||
[{row: 1, column: 0}, {row: 1, column: 5}],
|
||||
[{row: 1, column: 6}, {row: 1, column: 11}]]
|
||||
ranges.forEach(function(r) {
|
||||
sel.addRange(Range.fromPoints(r[0], r[1]));
|
||||
});
|
||||
assert.equal("foo\nhello\nworld", editor.getSelectedText());
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.equal("foo\nhello\nworld", editor.getSelectedText());
|
||||
assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), "selections dir not inverted");
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with multi cursors": function() {
|
||||
initEditor('foo\nhello world\n123');
|
||||
var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}],
|
||||
[{row: 1, column: 0}, {row: 1, column: 5}],
|
||||
[{row: 1, column: 6}, {row: 1, column: 11}]];
|
||||
// move cursors to the start of each range and set a mark to its end
|
||||
// without selecting anything
|
||||
ranges.forEach(function(r) {
|
||||
editor.pushEmacsMark(r[1]);
|
||||
sel.addRange(Range.fromPoints(r[0], r[0]));
|
||||
});
|
||||
assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), print(sel.getAllRanges()));
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.deepEqual(pluck(ranges, 1), pluck(sel.getAllRanges(), 'cursor'), "not inverted: " + print(sel.getAllRanges()));
|
||||
},
|
||||
|
||||
"test: setMark with multi cursors": function() {
|
||||
initEditor('foo\nhello world\n123');
|
||||
var positions = [{row: 0, column: 0},
|
||||
{row: 1, column: 0},
|
||||
{row: 1, column: 6}];
|
||||
positions.forEach(function(p) { sel.addRange(Range.fromPoints(p,p)); });
|
||||
editor.execCommand('setMark');
|
||||
assert.deepEqual(positions, editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,25 +33,37 @@ define(function(require, exports, module) {
|
|||
|
||||
var keyUtil = require("../lib/keys");
|
||||
var useragent = require("../lib/useragent");
|
||||
var KEY_MODS = keyUtil.KEY_MODS;
|
||||
|
||||
function HashHandler(config, platform) {
|
||||
this.platform = platform || (useragent.isMac ? "mac" : "win");
|
||||
this.commands = {};
|
||||
this.commandKeyBinding = {};
|
||||
|
||||
// todo remove this after a while
|
||||
if (this.__defineGetter__ && this.__defineSetter__ && typeof console != "undefined" && console.error) {
|
||||
var warned = false;
|
||||
var warn = function() {
|
||||
if (!warned) {
|
||||
warned = true;
|
||||
console.error("commmandKeyBinding has too many m's. use commandKeyBinding");
|
||||
}
|
||||
};
|
||||
this.__defineGetter__("commmandKeyBinding", function() {
|
||||
warn();
|
||||
return this.commandKeyBinding;
|
||||
});
|
||||
this.__defineSetter__("commmandKeyBinding", function(val) {
|
||||
warn();
|
||||
return this.commandKeyBinding = val;
|
||||
});
|
||||
} else {
|
||||
this.commmandKeyBinding = this.commandKeyBinding;
|
||||
}
|
||||
|
||||
this.addCommands(config);
|
||||
this.$singleCommand = true;
|
||||
}
|
||||
|
||||
function MultiHashHandler(config, platform) {
|
||||
HashHandler.call(this, config, platform);
|
||||
this.$singleCommand = false;
|
||||
}
|
||||
|
||||
MultiHashHandler.prototype = HashHandler.prototype;
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
this.addCommand = function(command) {
|
||||
if (this.commands[command.name])
|
||||
|
|
@ -63,92 +75,36 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
|||
this._buildKeyHash(command);
|
||||
};
|
||||
|
||||
this.removeCommand = function(command, keepCommand) {
|
||||
var name = command && (typeof command === 'string' ? command : command.name);
|
||||
this.removeCommand = function(command) {
|
||||
var name = (typeof command === 'string' ? command : command.name);
|
||||
command = this.commands[name];
|
||||
if (!keepCommand)
|
||||
delete this.commands[name];
|
||||
delete this.commands[name];
|
||||
|
||||
// exhaustive search is brute force but since removeCommand is
|
||||
// not a performance critical operation this should be OK
|
||||
var ckb = this.commandKeyBinding;
|
||||
for (var keyId in ckb) {
|
||||
var cmdGroup = ckb[keyId];
|
||||
if (cmdGroup == command) {
|
||||
delete ckb[keyId];
|
||||
} else if (Array.isArray(cmdGroup)) {
|
||||
var i = cmdGroup.indexOf(command);
|
||||
if (i != -1) {
|
||||
cmdGroup.splice(i, 1);
|
||||
if (cmdGroup.length == 1)
|
||||
ckb[keyId] = cmdGroup[0];
|
||||
}
|
||||
for (var hashId in ckb) {
|
||||
for (var key in ckb[hashId]) {
|
||||
if (ckb[hashId][key] == command)
|
||||
delete ckb[hashId][key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.bindKey = function(key, command, position) {
|
||||
if (typeof key == "object") {
|
||||
if (position == undefined)
|
||||
position = key.position;
|
||||
key = key[this.platform];
|
||||
}
|
||||
if (!key)
|
||||
this.bindKey = function(key, command) {
|
||||
if(!key)
|
||||
return;
|
||||
if (typeof command == "function") {
|
||||
this.addCommand({exec: command, bindKey: key, name: command.name || key});
|
||||
return;
|
||||
if (typeof command == "function")
|
||||
return this.addCommand({exec: command, bindKey: key, name: command.name || key});
|
||||
|
||||
key.split("|").forEach(function(keyPart) {
|
||||
var chain = "";
|
||||
if (keyPart.indexOf(" ") != -1) {
|
||||
var parts = keyPart.split(/\s+/);
|
||||
keyPart = parts.pop();
|
||||
parts.forEach(function(keyPart) {
|
||||
var binding = this.parseKeys(keyPart);
|
||||
var id = KEY_MODS[binding.hashId] + binding.key;
|
||||
chain += (chain ? " " : "") + id;
|
||||
this._addCommandToBinding(chain, "chainKeys");
|
||||
}, this);
|
||||
chain += " ";
|
||||
}
|
||||
var binding = this.parseKeys(keyPart);
|
||||
var id = KEY_MODS[binding.hashId] + binding.key;
|
||||
this._addCommandToBinding(chain + id, command, position);
|
||||
}, this);
|
||||
};
|
||||
|
||||
function getPosition(command) {
|
||||
return typeof command == "object" && command.bindKey
|
||||
&& command.bindKey.position || 0;
|
||||
}
|
||||
this._addCommandToBinding = function(keyId, command, position) {
|
||||
var ckb = this.commandKeyBinding, i;
|
||||
if (!command) {
|
||||
delete ckb[keyId];
|
||||
} else if (!ckb[keyId] || this.$singleCommand) {
|
||||
ckb[keyId] = command;
|
||||
} else {
|
||||
if (!Array.isArray(ckb[keyId])) {
|
||||
ckb[keyId] = [ckb[keyId]];
|
||||
} else if ((i = ckb[keyId].indexOf(command)) != -1) {
|
||||
ckb[keyId].splice(i, 1);
|
||||
}
|
||||
|
||||
if (typeof position != "number") {
|
||||
if (position || command.isDefault)
|
||||
position = -100;
|
||||
else
|
||||
position = getPosition(command);
|
||||
}
|
||||
var commands = ckb[keyId];
|
||||
for (i = 0; i < commands.length; i++) {
|
||||
var other = commands[i];
|
||||
var otherPos = getPosition(other);
|
||||
if (otherPos > position)
|
||||
break;
|
||||
}
|
||||
commands.splice(i, 0, command);
|
||||
}
|
||||
|
||||
var ckb = this.commandKeyBinding;
|
||||
key.split("|").forEach(function(keyPart) {
|
||||
var binding = this.parseKeys(keyPart, command);
|
||||
var hashId = binding.hashId;
|
||||
(ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.addCommands = function(commands) {
|
||||
|
|
@ -186,12 +142,21 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
|||
};
|
||||
|
||||
this._buildKeyHash = function(command) {
|
||||
this.bindKey(command.bindKey, command);
|
||||
var binding = command.bindKey;
|
||||
if (!binding)
|
||||
return;
|
||||
|
||||
var key = typeof binding == "string" ? binding: binding[this.platform];
|
||||
this.bindKey(key, command);
|
||||
};
|
||||
|
||||
// accepts keys in the form ctrl+Enter or ctrl-Enter
|
||||
// keys without modifiers or shift only
|
||||
this.parseKeys = function(keys) {
|
||||
// todo support keychains
|
||||
if (keys.indexOf(" ") != -1)
|
||||
keys = keys.split(/\s+/).pop();
|
||||
|
||||
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
|
||||
var key = parts.pop();
|
||||
|
||||
|
|
@ -208,7 +173,7 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
|||
var modifier = keyUtil.KEY_MODS[parts[i]];
|
||||
if (modifier == null) {
|
||||
if (typeof console != "undefined")
|
||||
console.error("invalid modifier " + parts[i] + " in " + keys);
|
||||
console.error("invalid modifier " + parts[i] + " in " + keys);
|
||||
return false;
|
||||
}
|
||||
hashId |= modifier;
|
||||
|
|
@ -217,40 +182,17 @@ MultiHashHandler.prototype = HashHandler.prototype;
|
|||
};
|
||||
|
||||
this.findKeyCommand = function findKeyCommand(hashId, keyString) {
|
||||
var key = KEY_MODS[hashId] + keyString;
|
||||
return this.commandKeyBinding[key];
|
||||
var ckbr = this.commandKeyBinding;
|
||||
return ckbr[hashId] && ckbr[hashId][keyString];
|
||||
};
|
||||
|
||||
this.handleKeyboard = function(data, hashId, keyString, keyCode) {
|
||||
var key = KEY_MODS[hashId] + keyString;
|
||||
var command = this.commandKeyBinding[key];
|
||||
if (data.$keyChain) {
|
||||
data.$keyChain += " " + key;
|
||||
command = this.commandKeyBinding[data.$keyChain] || command;
|
||||
}
|
||||
|
||||
if (command) {
|
||||
if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
|
||||
data.$keyChain = data.$keyChain || key;
|
||||
return {command: "null"};
|
||||
}
|
||||
}
|
||||
|
||||
if (data.$keyChain) {
|
||||
if ((!hashId || hashId == 4) && keyString.length == 1)
|
||||
data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
|
||||
else if (hashId == -1 || keyCode > 0)
|
||||
data.$keyChain = ""; // reset keyChain
|
||||
}
|
||||
return {command: command};
|
||||
};
|
||||
|
||||
this.getStatusText = function(editor, data) {
|
||||
return data.$keyChain || "";
|
||||
return {
|
||||
command: this.findKeyCommand(hashId, keyString)
|
||||
};
|
||||
};
|
||||
|
||||
}).call(HashHandler.prototype);
|
||||
}).call(HashHandler.prototype)
|
||||
|
||||
exports.HashHandler = HashHandler;
|
||||
exports.MultiHashHandler = MultiHashHandler;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -89,16 +89,8 @@ var KeyBinding = function(editor) {
|
|||
this.getKeyboardHandler = function() {
|
||||
return this.$handlers[this.$handlers.length - 1];
|
||||
};
|
||||
|
||||
this.getStatusText = function() {
|
||||
var data = this.$data;
|
||||
var editor = data.editor;
|
||||
return this.$handlers.map(function(h) {
|
||||
return h.getStatusText && h.getStatusText(editor, data) || "";
|
||||
}).filter(Boolean).join(" ");
|
||||
};
|
||||
|
||||
this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
|
||||
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
|
||||
var toExecute;
|
||||
var success = false;
|
||||
var commands = this.$editor.commands;
|
||||
|
|
|
|||
|
|
@ -45,13 +45,12 @@ var TextInput = function(parentNode, host) {
|
|||
if (useragent.isTouchPad)
|
||||
text.setAttribute("x-palm-disable-auto-cap", true);
|
||||
|
||||
text.setAttribute("wrap", "off");
|
||||
text.setAttribute("autocorrect", "off");
|
||||
text.setAttribute("autocapitalize", "off");
|
||||
text.setAttribute("spellcheck", false);
|
||||
text.wrap = "off";
|
||||
text.autocorrect = "off";
|
||||
text.autocapitalize = "off";
|
||||
text.spellcheck = false;
|
||||
|
||||
text.style.opacity = "0";
|
||||
if (useragent.isOldIE) text.style.top = "-1000px";
|
||||
parentNode.insertBefore(text, parentNode.firstChild);
|
||||
|
||||
var PLACEHOLDER = "\x01\x01";
|
||||
|
|
@ -66,24 +65,16 @@ var TextInput = function(parentNode, host) {
|
|||
// ie9 throws error if document.activeElement is accessed too soon
|
||||
try { var isFocused = document.activeElement === text; } catch(e) {}
|
||||
|
||||
event.addListener(text, "blur", function(e) {
|
||||
host.onBlur(e);
|
||||
event.addListener(text, "blur", function() {
|
||||
host.onBlur();
|
||||
isFocused = false;
|
||||
});
|
||||
event.addListener(text, "focus", function(e) {
|
||||
event.addListener(text, "focus", function() {
|
||||
isFocused = true;
|
||||
host.onFocus(e);
|
||||
host.onFocus();
|
||||
resetSelection();
|
||||
});
|
||||
this.focus = function() {
|
||||
if (tempStyle) return text.focus();
|
||||
text.style.position = "fixed";
|
||||
text.style.top = "-1000px";
|
||||
text.focus();
|
||||
setTimeout(function() {
|
||||
text.style.position = "";
|
||||
}, 0);
|
||||
};
|
||||
this.focus = function() { text.focus(); };
|
||||
this.blur = function() { text.blur(); };
|
||||
this.isFocused = function() {
|
||||
return isFocused;
|
||||
|
|
@ -103,11 +94,6 @@ var TextInput = function(parentNode, host) {
|
|||
function resetSelection(isEmpty) {
|
||||
if (inComposition)
|
||||
return;
|
||||
|
||||
// this prevents infinite recursion on safari 8
|
||||
// see https://github.com/ajaxorg/ace/issues/2114
|
||||
inComposition = true;
|
||||
|
||||
if (inputHandler) {
|
||||
selectionStart = 0;
|
||||
selectionEnd = isEmpty ? 0 : text.value.length - 1;
|
||||
|
|
@ -119,8 +105,6 @@ var TextInput = function(parentNode, host) {
|
|||
try {
|
||||
text.setSelectionRange(selectionStart, selectionEnd);
|
||||
} catch(e){}
|
||||
|
||||
inComposition = false;
|
||||
}
|
||||
|
||||
function resetValue() {
|
||||
|
|
@ -271,7 +255,7 @@ var TextInput = function(parentNode, host) {
|
|||
} else {
|
||||
return clipboardData.getData(mime);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var doCopy = function(e, isCut) {
|
||||
var data = host.getCopyText();
|
||||
|
|
@ -296,17 +280,17 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
var onCut = function(e) {
|
||||
doCopy(e, true);
|
||||
};
|
||||
}
|
||||
|
||||
var onCopy = function(e) {
|
||||
doCopy(e, false);
|
||||
};
|
||||
}
|
||||
|
||||
var onPaste = function(e) {
|
||||
var data = handleClipboardData(e);
|
||||
if (typeof data == "string") {
|
||||
if (data)
|
||||
host.onPaste(data, e);
|
||||
host.onPaste(data);
|
||||
if (useragent.isIE)
|
||||
setTimeout(resetSelection);
|
||||
event.preventDefault(e);
|
||||
|
|
@ -351,8 +335,7 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
// COMPOSITION
|
||||
var onCompositionStart = function(e) {
|
||||
if (inComposition || !host.onCompositionStart || host.$readOnly)
|
||||
return;
|
||||
if (inComposition || !host.onCompositionStart) return;
|
||||
// console.log("onCompositionStart", inComposition)
|
||||
inComposition = {};
|
||||
host.onCompositionStart();
|
||||
|
|
@ -368,8 +351,7 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
var onCompositionUpdate = function() {
|
||||
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
|
||||
if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
|
||||
return;
|
||||
if (!inComposition || !host.onCompositionUpdate) return;
|
||||
var val = text.value.replace(/\x01/g, "");
|
||||
if (inComposition.lastValue === val) return;
|
||||
|
||||
|
|
@ -388,7 +370,7 @@ var TextInput = function(parentNode, host) {
|
|||
};
|
||||
|
||||
var onCompositionEnd = function(e) {
|
||||
if (!host.onCompositionEnd || host.$readOnly) return;
|
||||
if (!host.onCompositionEnd) return;
|
||||
// console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
|
||||
var c = inComposition;
|
||||
inComposition = false;
|
||||
|
|
@ -397,7 +379,7 @@ var TextInput = function(parentNode, host) {
|
|||
var str = text.value.replace(/\x01/g, "");
|
||||
// console.log(str, c.lastValue)
|
||||
if (inComposition)
|
||||
return;
|
||||
return
|
||||
else if (str == c.lastValue)
|
||||
resetValue();
|
||||
else if (!c.lastValue && str) {
|
||||
|
|
@ -452,19 +434,16 @@ var TextInput = function(parentNode, host) {
|
|||
};
|
||||
|
||||
this.moveToMouse = function(e, bringToFront) {
|
||||
if (!bringToFront && useragent.isOldIE)
|
||||
return;
|
||||
if (!tempStyle)
|
||||
tempStyle = text.style.cssText;
|
||||
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
|
||||
+ "height:" + text.style.height + ";"
|
||||
+ (useragent.isIE ? "opacity:0.1;" : "");
|
||||
|
||||
var rect = host.container.getBoundingClientRect();
|
||||
var style = dom.computedStyle(host.container);
|
||||
var top = rect.top + (parseInt(style.borderTopWidth) || 0);
|
||||
var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
|
||||
var maxTop = rect.bottom - top - text.clientHeight -2;
|
||||
var maxTop = rect.bottom - top - text.clientHeight;
|
||||
var move = function(e) {
|
||||
text.style.left = e.clientX - left - 2 + "px";
|
||||
text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
|
||||
|
|
@ -478,15 +457,13 @@ var TextInput = function(parentNode, host) {
|
|||
host.renderer.$keepTextAreaAtCursor = null;
|
||||
|
||||
// on windows context menu is opened after mouseup
|
||||
if (useragent.isWin && !useragent.isOldIE)
|
||||
if (useragent.isWin)
|
||||
event.capture(host.container, move, onContextMenuClose);
|
||||
};
|
||||
|
||||
this.onContextMenuClose = onContextMenuClose;
|
||||
var closeTimeout;
|
||||
function onContextMenuClose() {
|
||||
clearTimeout(closeTimeout)
|
||||
closeTimeout = setTimeout(function () {
|
||||
setTimeout(function () {
|
||||
if (tempStyle) {
|
||||
text.style.cssText = tempStyle;
|
||||
tempStyle = '';
|
||||
|
|
@ -495,15 +472,18 @@ var TextInput = function(parentNode, host) {
|
|||
host.renderer.$keepTextAreaAtCursor = true;
|
||||
host.renderer.$moveTextAreaToCursor();
|
||||
}
|
||||
}, useragent.isOldIE ? 200 : 0);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var onContextMenu = function(e) {
|
||||
host.textInput.onContextMenu(e);
|
||||
onContextMenuClose();
|
||||
};
|
||||
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
|
||||
event.addListener(text, "contextmenu", onContextMenu);
|
||||
// firefox fires contextmenu event after opening it
|
||||
if (!useragent.isGecko || useragent.isMac) {
|
||||
var onContextMenu = function(e) {
|
||||
host.textInput.onContextMenu(e);
|
||||
onContextMenuClose();
|
||||
};
|
||||
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
|
||||
event.addListener(text, "contextmenu", onContextMenu);
|
||||
}
|
||||
};
|
||||
|
||||
exports.TextInput = TextInput;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
620
lib/ace/keyboard/vim/commands.js
Normal file
620
lib/ace/keyboard/vim/commands.js
Normal file
|
|
@ -0,0 +1,620 @@
|
|||
/* ***** 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) {
|
||||
|
||||
"never use strict";
|
||||
|
||||
var lang = require("../../lib/lang");
|
||||
var util = require("./maps/util");
|
||||
var motions = require("./maps/motions");
|
||||
var operators = require("./maps/operators");
|
||||
var alias = require("./maps/aliases");
|
||||
var registers = require("./registers");
|
||||
|
||||
var NUMBER = 1;
|
||||
var OPERATOR = 2;
|
||||
var MOTION = 3;
|
||||
var ACTION = 4;
|
||||
var HMARGIN = 8; // Minimum amount of line separation between margins;
|
||||
|
||||
var repeat = function repeat(fn, count, args) {
|
||||
while (0 < count--)
|
||||
fn.apply(this, args);
|
||||
};
|
||||
|
||||
var ensureScrollMargin = function(editor) {
|
||||
var renderer = editor.renderer;
|
||||
var pos = renderer.$cursorLayer.getPixelPosition();
|
||||
|
||||
var top = pos.top;
|
||||
|
||||
var margin = HMARGIN * renderer.layerConfig.lineHeight;
|
||||
if (2 * margin > renderer.$size.scrollerHeight)
|
||||
margin = renderer.$size.scrollerHeight / 2;
|
||||
|
||||
if (renderer.scrollTop > top - margin) {
|
||||
renderer.session.setScrollTop(top - margin);
|
||||
}
|
||||
|
||||
if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) {
|
||||
renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight);
|
||||
}
|
||||
};
|
||||
|
||||
var actions = exports.actions = {
|
||||
"z": {
|
||||
param: true,
|
||||
fn: function(editor, range, count, param) {
|
||||
switch (param) {
|
||||
case "z":
|
||||
editor.renderer.alignCursor(null, 0.5);
|
||||
break;
|
||||
case "t":
|
||||
editor.renderer.alignCursor(null, 0);
|
||||
break;
|
||||
case "b":
|
||||
editor.renderer.alignCursor(null, 1);
|
||||
break;
|
||||
case "c":
|
||||
editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
|
||||
break;
|
||||
case "o":
|
||||
editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
|
||||
break;
|
||||
case "C":
|
||||
editor.session.foldAll();
|
||||
break;
|
||||
case "O":
|
||||
editor.session.unfold();
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
"r": {
|
||||
param: true,
|
||||
fn: function(editor, range, count, param) {
|
||||
if (param && param.length) {
|
||||
if (param.length > 1)
|
||||
param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
|
||||
repeat(function() { editor.insert(param); }, count || 1);
|
||||
editor.navigateLeft();
|
||||
}
|
||||
}
|
||||
},
|
||||
"R": {
|
||||
fn: function(editor, range, count, param) {
|
||||
util.insertMode(editor);
|
||||
editor.setOverwrite(true);
|
||||
}
|
||||
},
|
||||
"~": {
|
||||
fn: function(editor, range, count) {
|
||||
repeat(function() {
|
||||
var range = editor.selection.getRange();
|
||||
if (range.isEmpty())
|
||||
range.end.column++;
|
||||
var text = editor.session.getTextRange(range);
|
||||
var toggled = text.toUpperCase();
|
||||
if (toggled != text)
|
||||
editor.session.replace(range, toggled);
|
||||
else if (text.toLowerCase() != text)
|
||||
editor.session.replace(range, text.toLowerCase())
|
||||
else
|
||||
editor.navigateRight();
|
||||
}, count || 1);
|
||||
}
|
||||
},
|
||||
"*": {
|
||||
fn: function(editor, range, count, param) {
|
||||
editor.selection.selectWord();
|
||||
editor.findNext();
|
||||
ensureScrollMargin(editor);
|
||||
var r = editor.selection.getRange();
|
||||
editor.selection.setSelectionRange(r, true);
|
||||
}
|
||||
},
|
||||
"#": {
|
||||
fn: function(editor, range, count, param) {
|
||||
editor.selection.selectWord();
|
||||
editor.findPrevious();
|
||||
ensureScrollMargin(editor);
|
||||
var r = editor.selection.getRange();
|
||||
editor.selection.setSelectionRange(r, true);
|
||||
}
|
||||
},
|
||||
"m": {
|
||||
param: true,
|
||||
fn: function(editor, range, count, param) {
|
||||
var s = editor.session;
|
||||
var markers = s.vimMarkers || (s.vimMarkers = {});
|
||||
var c = editor.getCursorPosition();
|
||||
if (!markers[param]) {
|
||||
markers[param] = editor.session.doc.createAnchor(c);
|
||||
}
|
||||
markers[param].setPosition(c.row, c.column, true);
|
||||
}
|
||||
},
|
||||
"n": {
|
||||
fn: function(editor, range, count, param) {
|
||||
var options = editor.getLastSearchOptions();
|
||||
options.backwards = false;
|
||||
options.start = null;
|
||||
|
||||
editor.selection.moveCursorRight();
|
||||
editor.selection.clearSelection();
|
||||
editor.findNext(options);
|
||||
|
||||
ensureScrollMargin(editor);
|
||||
var r = editor.selection.getRange();
|
||||
r.end.row = r.start.row;
|
||||
r.end.column = r.start.column;
|
||||
editor.selection.setSelectionRange(r, true);
|
||||
}
|
||||
},
|
||||
"N": {
|
||||
fn: function(editor, range, count, param) {
|
||||
var options = editor.getLastSearchOptions();
|
||||
options.backwards = true;
|
||||
options.start = null;
|
||||
|
||||
editor.findPrevious(options);
|
||||
ensureScrollMargin(editor);
|
||||
var r = editor.selection.getRange();
|
||||
r.end.row = r.start.row;
|
||||
r.end.column = r.start.column;
|
||||
editor.selection.setSelectionRange(r, true);
|
||||
}
|
||||
},
|
||||
"v": {
|
||||
fn: function(editor, range, count, param) {
|
||||
editor.selection.selectRight();
|
||||
util.visualMode(editor, false);
|
||||
},
|
||||
acceptsMotion: true
|
||||
},
|
||||
"V": {
|
||||
fn: function(editor, range, count, param) {
|
||||
//editor.selection.selectLine();
|
||||
//editor.selection.selectLeft();
|
||||
var row = editor.getCursorPosition().row;
|
||||
editor.selection.moveTo(row, 0);
|
||||
editor.selection.selectLineEnd();
|
||||
editor.selection.visualLineStart = row;
|
||||
|
||||
util.visualMode(editor, true);
|
||||
},
|
||||
acceptsMotion: true
|
||||
},
|
||||
"Y": {
|
||||
fn: function(editor, range, count, param) {
|
||||
util.copyLine(editor);
|
||||
}
|
||||
},
|
||||
"p": {
|
||||
fn: function(editor, range, count, param) {
|
||||
var defaultReg = registers._default;
|
||||
|
||||
editor.setOverwrite(false);
|
||||
if (defaultReg.isLine) {
|
||||
var pos = editor.getCursorPosition();
|
||||
pos.column = editor.session.getLine(pos.row).length;
|
||||
var text = lang.stringRepeat("\n" + defaultReg.text, count || 1);
|
||||
editor.session.insert(pos, text);
|
||||
editor.moveCursorTo(pos.row + 1, 0);
|
||||
}
|
||||
else {
|
||||
editor.navigateRight();
|
||||
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
||||
editor.navigateLeft();
|
||||
}
|
||||
editor.setOverwrite(true);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
},
|
||||
"P": {
|
||||
fn: function(editor, range, count, param) {
|
||||
var defaultReg = registers._default;
|
||||
editor.setOverwrite(false);
|
||||
|
||||
if (defaultReg.isLine) {
|
||||
var pos = editor.getCursorPosition();
|
||||
pos.column = 0;
|
||||
var text = lang.stringRepeat(defaultReg.text + "\n", count || 1);
|
||||
editor.session.insert(pos, text);
|
||||
editor.moveCursorToPosition(pos);
|
||||
}
|
||||
else {
|
||||
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
||||
}
|
||||
editor.setOverwrite(true);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
},
|
||||
"J": {
|
||||
fn: function(editor, range, count, param) {
|
||||
var session = editor.session;
|
||||
range = editor.getSelectionRange();
|
||||
var pos = {row: range.start.row, column: range.start.column};
|
||||
count = count || range.end.row - range.start.row;
|
||||
var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1);
|
||||
|
||||
range.start.column = session.getLine(pos.row).length;
|
||||
range.end.column = session.getLine(maxRow).length;
|
||||
range.end.row = maxRow;
|
||||
|
||||
var text = "";
|
||||
for (var i = pos.row; i < maxRow; i++) {
|
||||
var nextLine = session.getLine(i + 1);
|
||||
text += " " + /^\s*(.*)$/.exec(nextLine)[1] || "";
|
||||
}
|
||||
|
||||
session.replace(range, text);
|
||||
editor.moveCursorTo(pos.row, pos.column);
|
||||
}
|
||||
},
|
||||
"u": {
|
||||
fn: function(editor, range, count, param) {
|
||||
count = parseInt(count || 1, 10);
|
||||
for (var i = 0; i < count; i++) {
|
||||
editor.undo();
|
||||
}
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
},
|
||||
"ctrl-r": {
|
||||
fn: function(editor, range, count, param) {
|
||||
count = parseInt(count || 1, 10);
|
||||
for (var i = 0; i < count; i++) {
|
||||
editor.redo();
|
||||
}
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
},
|
||||
":": {
|
||||
fn: function(editor, range, count, param) {
|
||||
var val = ":";
|
||||
if (count > 1)
|
||||
val = ".,.+" + count + val;
|
||||
if (editor.showCommandLine)
|
||||
editor.showCommandLine(val);
|
||||
}
|
||||
},
|
||||
"/": {
|
||||
fn: function(editor, range, count, param) {
|
||||
if (editor.showCommandLine)
|
||||
editor.showCommandLine("/");
|
||||
}
|
||||
},
|
||||
"?": {
|
||||
fn: function(editor, range, count, param) {
|
||||
if (editor.showCommandLine)
|
||||
editor.showCommandLine("?");
|
||||
}
|
||||
},
|
||||
".": {
|
||||
fn: function(editor, range, count, param) {
|
||||
util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
|
||||
var previous = inputBuffer.previous;
|
||||
if (previous) // If there is a previous action
|
||||
inputBuffer.exec(editor, previous.action, previous.param);
|
||||
}
|
||||
},
|
||||
"ctrl-x": {
|
||||
fn: function(editor, range, count, param) {
|
||||
editor.modifyNumber(-(count || 1));
|
||||
}
|
||||
},
|
||||
"ctrl-a": {
|
||||
fn: function(editor, range, count, param) {
|
||||
editor.modifyNumber(count || 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var inputBuffer = exports.inputBuffer = {
|
||||
accepting: [NUMBER, OPERATOR, MOTION, ACTION],
|
||||
currentCmd: null,
|
||||
//currentMode: 0,
|
||||
currentCount: "",
|
||||
pendingCount: "",
|
||||
status: "",
|
||||
|
||||
// Types
|
||||
operator: null,
|
||||
motion: null,
|
||||
|
||||
lastInsertCommands: [],
|
||||
|
||||
push: function(editor, ch, keyId) {
|
||||
var status = this.status;
|
||||
var isKeyHandled = true;
|
||||
this.idle = false;
|
||||
var wObj = this.waitingForParam;
|
||||
if (/^numpad\d+$/i.test(ch))
|
||||
ch = ch.substr(6);
|
||||
|
||||
if (wObj) {
|
||||
this.exec(editor, wObj, ch);
|
||||
}
|
||||
// If input is a number (that doesn't start with 0)
|
||||
else if (!(ch === "0" && !this.currentCount.length) &&
|
||||
(/^\d+$/.test(ch) && this.isAccepting(NUMBER))) {
|
||||
// Assuming that ch is always of type String, and not Number
|
||||
this.currentCount += ch;
|
||||
this.currentCmd = NUMBER;
|
||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
||||
}
|
||||
else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
|
||||
this.operator = {
|
||||
ch: ch,
|
||||
count: this.getCount()
|
||||
};
|
||||
this.currentCmd = OPERATOR;
|
||||
this.accepting = [NUMBER, MOTION, ACTION];
|
||||
this.exec(editor, { operator: this.operator });
|
||||
}
|
||||
else if (motions[ch] && this.isAccepting(MOTION)) {
|
||||
this.currentCmd = MOTION;
|
||||
|
||||
var ctx = {
|
||||
operator: this.operator,
|
||||
motion: {
|
||||
ch: ch,
|
||||
count: this.getCount()
|
||||
}
|
||||
};
|
||||
|
||||
if (motions[ch].param)
|
||||
this.waitForParam(ctx);
|
||||
else
|
||||
this.exec(editor, ctx);
|
||||
}
|
||||
else if (alias[ch] && this.isAccepting(MOTION)) {
|
||||
alias[ch].operator.count = this.getCount();
|
||||
this.exec(editor, alias[ch]);
|
||||
}
|
||||
else if (actions[ch] && this.isAccepting(ACTION)) {
|
||||
var actionObj = {
|
||||
action: {
|
||||
fn: actions[ch].fn,
|
||||
count: this.getCount()
|
||||
}
|
||||
};
|
||||
|
||||
if (actions[ch].param) {
|
||||
this.waitForParam(actionObj);
|
||||
}
|
||||
else {
|
||||
this.exec(editor, actionObj);
|
||||
}
|
||||
|
||||
if (actions[ch].acceptsMotion)
|
||||
this.idle = false;
|
||||
}
|
||||
else if (this.operator) {
|
||||
this.operator.count = this.getCount();
|
||||
this.exec(editor, { operator: this.operator }, ch);
|
||||
}
|
||||
else {
|
||||
isKeyHandled = ch.length == 1;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
if (this.waitingForParam || this.motion || this.operator) {
|
||||
this.status += ch;
|
||||
} else if (this.currentCount) {
|
||||
this.status = this.currentCount;
|
||||
} else if (this.status) {
|
||||
this.status = "";
|
||||
}
|
||||
if (this.status != status)
|
||||
editor._emit("changeStatus");
|
||||
return isKeyHandled;
|
||||
},
|
||||
|
||||
waitForParam: function(cmd) {
|
||||
this.waitingForParam = cmd;
|
||||
},
|
||||
|
||||
getCount: function() {
|
||||
var count = this.currentCount || this.pendingCount;
|
||||
this.currentCount = "";
|
||||
this.pendingCount = count;
|
||||
return count && parseInt(count, 10);
|
||||
},
|
||||
|
||||
exec: function(editor, action, param) {
|
||||
var m = action.motion;
|
||||
var o = action.operator;
|
||||
var a = action.action;
|
||||
|
||||
if (!param)
|
||||
param = action.param;
|
||||
|
||||
if (o) {
|
||||
this.previous = {
|
||||
action: action,
|
||||
param: param
|
||||
};
|
||||
}
|
||||
|
||||
if (o && !editor.selection.isEmpty()) {
|
||||
if (operators[o.ch].selFn) {
|
||||
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
|
||||
this.reset();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// There is an operator, but no motion or action. We try to pass the
|
||||
// current ch to the operator to see if it responds to it (an example
|
||||
// of this is the 'dd' operator).
|
||||
else if (!m && !a && o && param) {
|
||||
operators[o.ch].fn(editor, null, o.count, param);
|
||||
this.reset();
|
||||
}
|
||||
else if (m) {
|
||||
var run = function(fn) {
|
||||
if (fn && typeof fn === "function") { // There should always be a motion
|
||||
if (m.count && !motionObj.handlesCount)
|
||||
repeat(fn, m.count, [editor, null, m.count, param]);
|
||||
else
|
||||
fn(editor, null, m.count, param);
|
||||
}
|
||||
};
|
||||
|
||||
var motionObj = motions[m.ch];
|
||||
var selectable = motionObj.sel;
|
||||
|
||||
if (!o) {
|
||||
if ((util.onVisualMode || util.onVisualLineMode) && selectable)
|
||||
run(motionObj.sel);
|
||||
else
|
||||
run(motionObj.nav);
|
||||
}
|
||||
else if (selectable) {
|
||||
repeat(function() {
|
||||
run(motionObj.sel);
|
||||
operators[o.ch].fn(editor, editor.getSelectionRange(),
|
||||
o.count, motionObj.param ? motionObj : param);
|
||||
}, o.count || 1);
|
||||
}
|
||||
this.reset();
|
||||
}
|
||||
else if (a) {
|
||||
a.fn(editor, editor.getSelectionRange(), a.count, param);
|
||||
this.reset();
|
||||
}
|
||||
handleCursorMove(editor);
|
||||
if (editor.curOp && editor.curOp.selectionChanged)
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
},
|
||||
|
||||
isAccepting: function(type) {
|
||||
return this.accepting.indexOf(type) !== -1;
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.operator = null;
|
||||
this.motion = null;
|
||||
this.currentCount = "";
|
||||
this.pendingCount = "";
|
||||
this.status = "";
|
||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
||||
this.idle = true;
|
||||
this.waitingForParam = null;
|
||||
}
|
||||
};
|
||||
|
||||
function setPreviousCommand(fn) {
|
||||
inputBuffer.previous = { action: { action: { fn: fn } } };
|
||||
}
|
||||
|
||||
exports.coreCommands = {
|
||||
start: {
|
||||
exec: function start(editor) {
|
||||
util.insertMode(editor);
|
||||
setPreviousCommand(start);
|
||||
}
|
||||
},
|
||||
startBeginning: {
|
||||
exec: function startBeginning(editor) {
|
||||
editor.navigateLineStart();
|
||||
util.insertMode(editor);
|
||||
setPreviousCommand(startBeginning);
|
||||
}
|
||||
},
|
||||
// Stop Insert mode as soon as possible. Works like typing <Esc> in
|
||||
// insert mode.
|
||||
stop: {
|
||||
exec: function stop(editor) {
|
||||
inputBuffer.reset();
|
||||
util.onVisualMode = false;
|
||||
util.onVisualLineMode = false;
|
||||
inputBuffer.lastInsertCommands = util.normalMode(editor);
|
||||
}
|
||||
},
|
||||
append: {
|
||||
exec: function append(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
var lineLen = editor.session.getLine(pos.row).length;
|
||||
if (lineLen)
|
||||
editor.navigateRight();
|
||||
util.insertMode(editor);
|
||||
setPreviousCommand(append);
|
||||
}
|
||||
},
|
||||
appendEnd: {
|
||||
exec: function appendEnd(editor) {
|
||||
editor.navigateLineEnd();
|
||||
util.insertMode(editor);
|
||||
setPreviousCommand(appendEnd);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var handleCursorMove = exports.onCursorMove = function(editor, e) {
|
||||
if (util.currentMode === 'insert' || handleCursorMove.running)
|
||||
return;
|
||||
else if(!editor.selection.isEmpty()) {
|
||||
handleCursorMove.running = true;
|
||||
if (util.onVisualLineMode) {
|
||||
var originRow = editor.selection.visualLineStart;
|
||||
var cursorRow = editor.getCursorPosition().row;
|
||||
if(originRow <= cursorRow) {
|
||||
var endLine = editor.session.getLine(cursorRow);
|
||||
editor.selection.moveTo(originRow, 0);
|
||||
editor.selection.selectTo(cursorRow, endLine.length);
|
||||
} else {
|
||||
var endLine = editor.session.getLine(originRow);
|
||||
editor.selection.moveTo(originRow, endLine.length);
|
||||
editor.selection.selectTo(cursorRow, 0);
|
||||
}
|
||||
}
|
||||
handleCursorMove.running = false;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (e && (util.onVisualLineMode || util.onVisualMode)) {
|
||||
editor.selection.clearSelection();
|
||||
util.normalMode(editor);
|
||||
}
|
||||
|
||||
handleCursorMove.running = true;
|
||||
var pos = editor.getCursorPosition();
|
||||
var lineLen = editor.session.getLine(pos.row).length;
|
||||
|
||||
if (lineLen && pos.column === lineLen)
|
||||
editor.navigateLeft();
|
||||
handleCursorMove.running = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
@ -27,36 +27,68 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
"use strict"
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var SqlServerHighlightRules = require("./sqlserver_highlight_rules").SqlHighlightRules;
|
||||
var Range = require("../range").Range;
|
||||
var SqlServerFoldMode = require("./folding/sqlserver").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = SqlServerHighlightRules;
|
||||
this.foldingRules = new SqlServerFoldMode();
|
||||
module.exports = {
|
||||
"x": {
|
||||
operator: {
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
ch: "l",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"X": {
|
||||
operator: {
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
ch: "h",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"D": {
|
||||
operator: {
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
ch: "$",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"C": {
|
||||
operator: {
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
ch: "$",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"s": {
|
||||
operator: {
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
ch: "l",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"S": {
|
||||
operator: {
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
param: "c"
|
||||
}
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
/**
|
||||
* Override keyword completions using list created in highlight rules
|
||||
*/
|
||||
this.getCompletions = function(state, session, pos, prefix) {
|
||||
return session.$mode.$highlightRules.completions;
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/sql";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
|
||||
681
lib/ace/keyboard/vim/maps/motions.js
Normal file
681
lib/ace/keyboard/vim/maps/motions.js
Normal file
|
|
@ -0,0 +1,681 @@
|
|||
/* ***** 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";
|
||||
|
||||
var util = require("./util");
|
||||
|
||||
var keepScrollPosition = function(editor, fn) {
|
||||
var scrollTopRow = editor.renderer.getScrollTopRow();
|
||||
var initialRow = editor.getCursorPosition().row;
|
||||
var diff = initialRow - scrollTopRow;
|
||||
fn && fn.call(editor);
|
||||
editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
|
||||
};
|
||||
|
||||
function Motion(m) {
|
||||
if (typeof m == "function") {
|
||||
var getPos = m;
|
||||
m = this;
|
||||
} else {
|
||||
var getPos = m.getPos;
|
||||
}
|
||||
m.nav = function(editor, range, count, param) {
|
||||
var a = getPos(editor, range, count, param, false);
|
||||
if (!a)
|
||||
return;
|
||||
editor.selection.moveTo(a.row, a.column);
|
||||
};
|
||||
m.sel = function(editor, range, count, param) {
|
||||
var a = getPos(editor, range, count, param, true);
|
||||
if (!a)
|
||||
return;
|
||||
editor.selection.selectTo(a.row, a.column);
|
||||
};
|
||||
return m;
|
||||
}
|
||||
|
||||
var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
||||
var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
||||
var whiteRe = /\s/;
|
||||
var StringStream = function(editor, cursor) {
|
||||
var sel = editor.selection;
|
||||
this.range = sel.getRange();
|
||||
cursor = cursor || sel.selectionLead;
|
||||
this.row = cursor.row;
|
||||
this.col = cursor.column;
|
||||
var line = editor.session.getLine(this.row);
|
||||
var maxRow = editor.session.getLength();
|
||||
this.ch = line[this.col] || '\n';
|
||||
this.skippedLines = 0;
|
||||
|
||||
this.next = function() {
|
||||
this.ch = line[++this.col] || this.handleNewLine(1);
|
||||
//this.debug()
|
||||
return this.ch;
|
||||
};
|
||||
this.prev = function() {
|
||||
this.ch = line[--this.col] || this.handleNewLine(-1);
|
||||
//this.debug()
|
||||
return this.ch;
|
||||
};
|
||||
this.peek = function(dir) {
|
||||
var ch = line[this.col + dir];
|
||||
if (ch)
|
||||
return ch;
|
||||
if (dir == -1)
|
||||
return '\n';
|
||||
if (this.col == line.length - 1)
|
||||
return '\n';
|
||||
return editor.session.getLine(this.row + 1)[0] || '\n';
|
||||
};
|
||||
|
||||
this.handleNewLine = function(dir) {
|
||||
if (dir == 1){
|
||||
if (this.col == line.length)
|
||||
return '\n';
|
||||
if (this.row == maxRow - 1)
|
||||
return '';
|
||||
this.col = 0;
|
||||
this.row ++;
|
||||
line = editor.session.getLine(this.row);
|
||||
this.skippedLines++;
|
||||
return line[0] || '\n';
|
||||
}
|
||||
if (dir == -1) {
|
||||
if (this.row === 0)
|
||||
return '';
|
||||
this.row --;
|
||||
line = editor.session.getLine(this.row);
|
||||
this.col = line.length;
|
||||
this.skippedLines--;
|
||||
return '\n';
|
||||
}
|
||||
};
|
||||
this.debug = function() {
|
||||
console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
|
||||
};
|
||||
};
|
||||
|
||||
var Search = require("../../../search").Search;
|
||||
var search = new Search();
|
||||
|
||||
function find(editor, needle, dir) {
|
||||
search.$options.needle = needle;
|
||||
search.$options.backwards = dir == -1;
|
||||
return search.find(editor.session);
|
||||
}
|
||||
|
||||
var Range = require("../../../range").Range;
|
||||
|
||||
var LAST_SEARCH_MOTION = {};
|
||||
|
||||
module.exports = {
|
||||
"w": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
|
||||
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
||||
while (str.ch && wordSeparatorRe.test(str.ch))
|
||||
str.next();
|
||||
} else {
|
||||
while (str.ch && !nonWordRe.test(str.ch))
|
||||
str.next();
|
||||
}
|
||||
while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2)
|
||||
str.next();
|
||||
|
||||
str.skippedLines == 2 && str.prev();
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"W": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2)
|
||||
str.next();
|
||||
if (str.skippedLines == 2)
|
||||
str.prev();
|
||||
else
|
||||
str.next();
|
||||
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"b": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
|
||||
str.prev();
|
||||
while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2)
|
||||
str.prev();
|
||||
|
||||
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
||||
while (str.ch && wordSeparatorRe.test(str.ch))
|
||||
str.prev();
|
||||
} else {
|
||||
while (str.ch && !nonWordRe.test(str.ch))
|
||||
str.prev();
|
||||
}
|
||||
str.ch && str.next();
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"B": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
str.prev();
|
||||
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
|
||||
str.prev();
|
||||
|
||||
if (str.skippedLines == -2)
|
||||
str.next();
|
||||
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"e": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
|
||||
str.next();
|
||||
while (str.ch && whiteRe.test(str.ch))
|
||||
str.next();
|
||||
|
||||
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
||||
while (str.ch && wordSeparatorRe.test(str.ch))
|
||||
str.next();
|
||||
} else {
|
||||
while (str.ch && !nonWordRe.test(str.ch))
|
||||
str.next();
|
||||
}
|
||||
str.ch && str.prev();
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"E": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
str.next();
|
||||
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1))))
|
||||
str.next();
|
||||
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
|
||||
"l": {
|
||||
nav: function(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
var col = pos.column;
|
||||
var lineLen = editor.session.getLine(pos.row).length;
|
||||
if (lineLen && col !== lineLen)
|
||||
editor.navigateRight();
|
||||
},
|
||||
sel: function(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
var col = pos.column;
|
||||
var lineLen = editor.session.getLine(pos.row).length;
|
||||
|
||||
// Solving the behavior at the end of the line due to the
|
||||
// different 0 index-based colum positions in ACE.
|
||||
if (lineLen && col !== lineLen) //In selection mode you can select the newline
|
||||
editor.selection.selectRight();
|
||||
}
|
||||
},
|
||||
"h": {
|
||||
nav: function(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
if (pos.column > 0)
|
||||
editor.navigateLeft();
|
||||
},
|
||||
sel: function(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
if (pos.column > 0)
|
||||
editor.selection.selectLeft();
|
||||
}
|
||||
},
|
||||
"H": {
|
||||
nav: function(editor) {
|
||||
var row = editor.renderer.getScrollTopRow();
|
||||
editor.moveCursorTo(row);
|
||||
},
|
||||
sel: function(editor) {
|
||||
var row = editor.renderer.getScrollTopRow();
|
||||
editor.selection.selectTo(row);
|
||||
}
|
||||
},
|
||||
"M": {
|
||||
nav: function(editor) {
|
||||
var topRow = editor.renderer.getScrollTopRow();
|
||||
var bottomRow = editor.renderer.getScrollBottomRow();
|
||||
var row = topRow + ((bottomRow - topRow) / 2);
|
||||
editor.moveCursorTo(row);
|
||||
},
|
||||
sel: function(editor) {
|
||||
var topRow = editor.renderer.getScrollTopRow();
|
||||
var bottomRow = editor.renderer.getScrollBottomRow();
|
||||
var row = topRow + ((bottomRow - topRow) / 2);
|
||||
editor.selection.selectTo(row);
|
||||
}
|
||||
},
|
||||
"L": {
|
||||
nav: function(editor) {
|
||||
var row = editor.renderer.getScrollBottomRow();
|
||||
editor.moveCursorTo(row);
|
||||
},
|
||||
sel: function(editor) {
|
||||
var row = editor.renderer.getScrollBottomRow();
|
||||
editor.selection.selectTo(row);
|
||||
}
|
||||
},
|
||||
"k": {
|
||||
nav: function(editor) {
|
||||
editor.navigateUp();
|
||||
},
|
||||
sel: function(editor) {
|
||||
editor.selection.selectUp();
|
||||
}
|
||||
},
|
||||
"j": {
|
||||
nav: function(editor) {
|
||||
editor.navigateDown();
|
||||
},
|
||||
sel: function(editor) {
|
||||
editor.selection.selectDown();
|
||||
}
|
||||
},
|
||||
|
||||
"i": {
|
||||
param: true,
|
||||
sel: function(editor, range, count, param) {
|
||||
switch (param) {
|
||||
case "w":
|
||||
editor.selection.selectWord();
|
||||
break;
|
||||
case "W":
|
||||
editor.selection.selectAWord();
|
||||
break;
|
||||
case "(":
|
||||
case "{":
|
||||
case "[":
|
||||
var cursor = editor.getCursorPosition();
|
||||
var end = editor.session.$findClosingBracket(param, cursor, /paren/);
|
||||
if (!end)
|
||||
return;
|
||||
var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
|
||||
if (!start)
|
||||
return;
|
||||
start.column ++;
|
||||
editor.selection.setSelectionRange(Range.fromPoints(start, end));
|
||||
break;
|
||||
case "'":
|
||||
case '"':
|
||||
case "/":
|
||||
var end = find(editor, param, 1);
|
||||
if (!end)
|
||||
return;
|
||||
var start = find(editor, param, -1);
|
||||
if (!start)
|
||||
return;
|
||||
editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start));
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
"a": {
|
||||
param: true,
|
||||
sel: function(editor, range, count, param) {
|
||||
switch (param) {
|
||||
case "w":
|
||||
editor.selection.selectAWord();
|
||||
break;
|
||||
case "W":
|
||||
editor.selection.selectAWord();
|
||||
break;
|
||||
case ")":
|
||||
case "}":
|
||||
case "]":
|
||||
param = editor.session.$brackets[param];
|
||||
case "(":
|
||||
case "{":
|
||||
case "[":
|
||||
var cursor = editor.getCursorPosition();
|
||||
var end = editor.session.$findClosingBracket(param, cursor, /paren/);
|
||||
if (!end)
|
||||
return;
|
||||
var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
|
||||
if (!start)
|
||||
return;
|
||||
end.column ++;
|
||||
editor.selection.setSelectionRange(Range.fromPoints(start, end));
|
||||
break;
|
||||
case "'":
|
||||
case "\"":
|
||||
case "/":
|
||||
var end = find(editor, param, 1);
|
||||
if (!end)
|
||||
return;
|
||||
var start = find(editor, param, -1);
|
||||
if (!start)
|
||||
return;
|
||||
end.column ++;
|
||||
editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end));
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"f": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "f", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
cursor.column += column + (isSel ? 2 : 1);
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
}),
|
||||
"F": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "F", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
cursor.column -= column + 1;
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
}),
|
||||
"t": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "t", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (isRepeat && column == 0 && !(count > 1))
|
||||
var column = util.getRightNthChar(editor, cursor, param, 2);
|
||||
|
||||
if (typeof column === "number") {
|
||||
cursor.column += column + (isSel ? 1 : 0);
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
}),
|
||||
"T": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "T", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (isRepeat && column == 0 && !(count > 1))
|
||||
var column = util.getLeftNthChar(editor, cursor, param, 2);
|
||||
|
||||
if (typeof column === "number") {
|
||||
cursor.column -= column;
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
}),
|
||||
";": new Motion({
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var ch = LAST_SEARCH_MOTION.ch;
|
||||
if (!ch)
|
||||
return;
|
||||
return module.exports[ch].getPos(
|
||||
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
||||
);
|
||||
}
|
||||
}),
|
||||
",": new Motion({
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var ch = LAST_SEARCH_MOTION.ch;
|
||||
if (!ch)
|
||||
return;
|
||||
var up = ch.toUpperCase();
|
||||
ch = ch === up ? ch.toLowerCase() : up;
|
||||
|
||||
return module.exports[ch].getPos(
|
||||
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
||||
);
|
||||
}
|
||||
}),
|
||||
|
||||
"^": {
|
||||
nav: function(editor) {
|
||||
editor.navigateLineStart();
|
||||
},
|
||||
sel: function(editor) {
|
||||
editor.selection.selectLineStart();
|
||||
}
|
||||
},
|
||||
"$": {
|
||||
handlesCount: true,
|
||||
nav: function(editor, range, count, param) {
|
||||
if (count > 1) {
|
||||
editor.navigateDown(count-1);
|
||||
}
|
||||
editor.navigateLineEnd();
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
if (count > 1) {
|
||||
editor.selection.moveCursorBy(count-1, 0);
|
||||
}
|
||||
editor.selection.selectLineEnd();
|
||||
}
|
||||
},
|
||||
"0": new Motion(function(ed) {
|
||||
return {row: ed.selection.lead.row, column: 0};
|
||||
}),
|
||||
"G": {
|
||||
nav: function(editor, range, count, param) {
|
||||
if (!count && count !== 0) { // Stupid JS
|
||||
count = editor.session.getLength();
|
||||
}
|
||||
editor.gotoLine(count);
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
if (!count && count !== 0) { // Stupid JS
|
||||
count = editor.session.getLength();
|
||||
}
|
||||
editor.selection.selectTo(count, 0);
|
||||
}
|
||||
},
|
||||
"g": {
|
||||
param: true,
|
||||
nav: function(editor, range, count, param) {
|
||||
switch(param) {
|
||||
case "m":
|
||||
console.log("Middle line");
|
||||
break;
|
||||
case "e":
|
||||
console.log("End of prev word");
|
||||
break;
|
||||
case "g":
|
||||
editor.gotoLine(count || 0);
|
||||
case "u":
|
||||
editor.gotoLine(count || 0);
|
||||
case "U":
|
||||
editor.gotoLine(count || 0);
|
||||
}
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
switch(param) {
|
||||
case "m":
|
||||
console.log("Middle line");
|
||||
break;
|
||||
case "e":
|
||||
console.log("End of prev word");
|
||||
break;
|
||||
case "g":
|
||||
editor.selection.selectTo(count || 0, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
"o": {
|
||||
nav: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
var content = "";
|
||||
while (0 < count--)
|
||||
content += "\n";
|
||||
|
||||
if (content.length) {
|
||||
editor.navigateLineEnd()
|
||||
editor.insert(content);
|
||||
util.insertMode(editor);
|
||||
}
|
||||
}
|
||||
},
|
||||
"O": {
|
||||
nav: function(editor, range, count, param) {
|
||||
var row = editor.getCursorPosition().row;
|
||||
count = count || 1;
|
||||
var content = "";
|
||||
while (0 < count--)
|
||||
content += "\n";
|
||||
|
||||
if (content.length) {
|
||||
if(row > 0) {
|
||||
editor.navigateUp();
|
||||
editor.navigateLineEnd()
|
||||
editor.insert(content);
|
||||
} else {
|
||||
editor.session.insert({row: 0, column: 0}, content);
|
||||
editor.navigateUp();
|
||||
}
|
||||
util.insertMode(editor);
|
||||
}
|
||||
}
|
||||
},
|
||||
"%": new Motion(function(editor){
|
||||
var brRe = /[\[\]{}()]/g;
|
||||
var cursor = editor.getCursorPosition();
|
||||
var ch = editor.session.getLine(cursor.row)[cursor.column];
|
||||
if (!brRe.test(ch)) {
|
||||
var range = find(editor, brRe);
|
||||
if (!range)
|
||||
return;
|
||||
cursor = range.start;
|
||||
}
|
||||
var match = editor.session.findMatchingBracket({
|
||||
row: cursor.row,
|
||||
column: cursor.column + 1
|
||||
});
|
||||
|
||||
return match;
|
||||
}),
|
||||
"{": new Motion(function(ed) {
|
||||
var session = ed.session;
|
||||
var row = session.selection.lead.row;
|
||||
while(row > 0 && !/\S/.test(session.getLine(row)))
|
||||
row--;
|
||||
while(/\S/.test(session.getLine(row)))
|
||||
row--;
|
||||
return {column: 0, row: row};
|
||||
}),
|
||||
"}": new Motion(function(ed) {
|
||||
var session = ed.session;
|
||||
var l = session.getLength();
|
||||
var row = session.selection.lead.row;
|
||||
while(row < l && !/\S/.test(session.getLine(row)))
|
||||
row++;
|
||||
while(/\S/.test(session.getLine(row)))
|
||||
row++;
|
||||
return {column: 0, row: row};
|
||||
}),
|
||||
"ctrl-d": {
|
||||
nav: function(editor, range, count, param) {
|
||||
editor.selection.clearSelection();
|
||||
keepScrollPosition(editor, editor.gotoPageDown);
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
keepScrollPosition(editor, editor.selectPageDown);
|
||||
}
|
||||
},
|
||||
"ctrl-u": {
|
||||
nav: function(editor, range, count, param) {
|
||||
editor.selection.clearSelection();
|
||||
keepScrollPosition(editor, editor.gotoPageUp);
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
keepScrollPosition(editor, editor.selectPageUp);
|
||||
}
|
||||
},
|
||||
"`": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var s = editor.session;
|
||||
var marker = s.vimMarkers && s.vimMarkers[param];
|
||||
if (marker) {
|
||||
return marker.getPosition();
|
||||
}
|
||||
}
|
||||
}),
|
||||
"'": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var s = editor.session;
|
||||
var marker = s.vimMarkers && s.vimMarkers[param];
|
||||
if (marker) {
|
||||
var pos = marker.getPosition();
|
||||
var line = editor.session.getLine(pos.row);
|
||||
pos.column = line.search(/\S/);
|
||||
if (pos.column == -1)
|
||||
pos.column = line.length;
|
||||
return pos;
|
||||
}
|
||||
},
|
||||
isLine: true
|
||||
})
|
||||
};
|
||||
|
||||
module.exports.backspace = module.exports.left = module.exports.h;
|
||||
module.exports.space = module.exports['return'] = module.exports.right = module.exports.l;
|
||||
module.exports.up = module.exports.k;
|
||||
module.exports.down = module.exports.j;
|
||||
module.exports.pagedown = module.exports["ctrl-d"];
|
||||
module.exports.pageup = module.exports["ctrl-u"];
|
||||
module.exports.home = module.exports["0"];
|
||||
module.exports.end = module.exports["$"];
|
||||
|
||||
});
|
||||
199
lib/ace/keyboard/vim/maps/operators.js
Normal file
199
lib/ace/keyboard/vim/maps/operators.js
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
/* ***** 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";
|
||||
|
||||
var util = require("./util");
|
||||
var registers = require("../registers");
|
||||
var Range = require("../../../range").Range;
|
||||
|
||||
module.exports = {
|
||||
"d": {
|
||||
selFn: function(editor, range, count, param) {
|
||||
registers._default.text = editor.getCopyText();
|
||||
registers._default.isLine = util.onVisualLineMode;
|
||||
if(util.onVisualLineMode)
|
||||
editor.removeLines();
|
||||
else
|
||||
editor.session.remove(range);
|
||||
util.normalMode(editor);
|
||||
},
|
||||
fn: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
switch (param) {
|
||||
case "d":
|
||||
registers._default.text = "";
|
||||
registers._default.isLine = true;
|
||||
for (var i = 0; i < count; i++) {
|
||||
editor.selection.selectLine();
|
||||
registers._default.text += editor.getCopyText();
|
||||
var selRange = editor.getSelectionRange();
|
||||
// check if end of the document was reached
|
||||
if (!selRange.isMultiLine()) {
|
||||
var row = selRange.start.row - 1;
|
||||
var col = editor.session.getLine(row).length
|
||||
selRange.setStart(row, col);
|
||||
editor.session.remove(selRange);
|
||||
editor.selection.clearSelection();
|
||||
break;
|
||||
}
|
||||
editor.session.remove(selRange);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
registers._default.text = registers._default.text.replace(/\n$/, "");
|
||||
break;
|
||||
default:
|
||||
if (range) {
|
||||
editor.selection.setSelectionRange(range);
|
||||
registers._default.text = editor.getCopyText();
|
||||
registers._default.isLine = false;
|
||||
editor.session.remove(range);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"c": {
|
||||
selFn: function(editor, range, count, param) {
|
||||
editor.session.remove(range);
|
||||
util.insertMode(editor);
|
||||
},
|
||||
fn: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
switch (param) {
|
||||
case "c":
|
||||
editor.selection.$moveSelection(function() {
|
||||
editor.selection.moveCursorBy(count - 1, 0);
|
||||
});
|
||||
var rows = editor.$getSelectedRows();
|
||||
range = new Range(rows.first, 0, rows.last, Infinity);
|
||||
editor.session.remove(range);
|
||||
util.insertMode(editor);
|
||||
break;
|
||||
default:
|
||||
if (range) {
|
||||
// range.end.column ++;
|
||||
editor.session.remove(range);
|
||||
util.insertMode(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"y": {
|
||||
selFn: function(editor, range, count, param) {
|
||||
registers._default.text = editor.getCopyText();
|
||||
registers._default.isLine = util.onVisualLineMode;
|
||||
editor.selection.clearSelection();
|
||||
util.normalMode(editor);
|
||||
},
|
||||
fn: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
if (param && param.isLine)
|
||||
param = "y";
|
||||
switch (param) {
|
||||
case "y":
|
||||
var pos = editor.getCursorPosition();
|
||||
editor.selection.selectLine();
|
||||
for (var i = 0; i < count - 1; i++) {
|
||||
editor.selection.moveCursorDown();
|
||||
}
|
||||
registers._default.text = editor.getCopyText().replace(/\n$/, "");
|
||||
editor.selection.clearSelection();
|
||||
registers._default.isLine = true;
|
||||
editor.moveCursorToPosition(pos);
|
||||
break;
|
||||
default:
|
||||
if (range) {
|
||||
var pos = editor.getCursorPosition();
|
||||
editor.selection.setSelectionRange(range);
|
||||
registers._default.text = editor.getCopyText();
|
||||
registers._default.isLine = false;
|
||||
editor.selection.clearSelection();
|
||||
editor.moveCursorTo(pos.row, pos.column);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
">": {
|
||||
selFn: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
for (var i = 0; i < count; i++) {
|
||||
editor.indent();
|
||||
}
|
||||
util.normalMode(editor);
|
||||
},
|
||||
fn: function(editor, range, count, param) {
|
||||
count = parseInt(count || 1, 10);
|
||||
switch (param) {
|
||||
case ">":
|
||||
var pos = editor.getCursorPosition();
|
||||
editor.selection.selectLine();
|
||||
for (var i = 0; i < count - 1; i++) {
|
||||
editor.selection.moveCursorDown();
|
||||
}
|
||||
editor.indent();
|
||||
editor.selection.clearSelection();
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.navigateLineEnd();
|
||||
editor.navigateLineStart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
"<": {
|
||||
selFn: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
for (var i = 0; i < count; i++) {
|
||||
editor.blockOutdent();
|
||||
}
|
||||
util.normalMode(editor);
|
||||
},
|
||||
fn: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
switch (param) {
|
||||
case "<":
|
||||
var pos = editor.getCursorPosition();
|
||||
editor.selection.selectLine();
|
||||
for (var i = 0; i < count - 1; i++) {
|
||||
editor.selection.moveCursorDown();
|
||||
}
|
||||
editor.blockOutdent();
|
||||
editor.selection.clearSelection();
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.navigateLineEnd();
|
||||
editor.navigateLineStart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
132
lib/ace/keyboard/vim/maps/util.js
Normal file
132
lib/ace/keyboard/vim/maps/util.js
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
define(function(require, exports, module) {
|
||||
var registers = require("../registers");
|
||||
|
||||
var dom = require("../../../lib/dom");
|
||||
dom.importCssString('.insert-mode .ace_cursor{\
|
||||
border-left: 2px solid #333333;\
|
||||
}\
|
||||
.ace_dark.insert-mode .ace_cursor{\
|
||||
border-left: 2px solid #eeeeee;\
|
||||
}\
|
||||
.normal-mode .ace_cursor{\
|
||||
border: 0!important;\
|
||||
background-color: red;\
|
||||
opacity: 0.5;\
|
||||
}', 'vimMode');
|
||||
|
||||
module.exports = {
|
||||
onVisualMode: false,
|
||||
onVisualLineMode: false,
|
||||
currentMode: 'normal',
|
||||
noMode: function(editor) {
|
||||
editor.unsetStyle('insert-mode');
|
||||
editor.unsetStyle('normal-mode');
|
||||
if (editor.commands.recording)
|
||||
editor.commands.toggleRecording(editor);
|
||||
editor.setOverwrite(false);
|
||||
},
|
||||
insertMode: function(editor) {
|
||||
this.currentMode = 'insert';
|
||||
// Switch editor to insert mode
|
||||
editor.setStyle('insert-mode');
|
||||
editor.unsetStyle('normal-mode');
|
||||
|
||||
editor.setOverwrite(false);
|
||||
editor.keyBinding.$data.buffer = "";
|
||||
editor.keyBinding.$data.vimState = "insertMode";
|
||||
this.onVisualMode = false;
|
||||
this.onVisualLineMode = false;
|
||||
if(this.onInsertReplaySequence) {
|
||||
// Ok, we're apparently replaying ("."), so let's do it
|
||||
editor.commands.macro = this.onInsertReplaySequence;
|
||||
editor.commands.replay(editor);
|
||||
this.onInsertReplaySequence = null;
|
||||
this.normalMode(editor);
|
||||
} else {
|
||||
editor._emit("changeStatus");
|
||||
// Record any movements, insertions in insert mode
|
||||
if(!editor.commands.recording)
|
||||
editor.commands.toggleRecording(editor);
|
||||
}
|
||||
},
|
||||
normalMode: function(editor) {
|
||||
// Switch editor to normal mode
|
||||
this.currentMode = 'normal';
|
||||
|
||||
editor.unsetStyle('insert-mode');
|
||||
editor.setStyle('normal-mode');
|
||||
editor.clearSelection();
|
||||
|
||||
var pos;
|
||||
if (!editor.getOverwrite()) {
|
||||
pos = editor.getCursorPosition();
|
||||
if (pos.column > 0)
|
||||
editor.navigateLeft();
|
||||
}
|
||||
|
||||
editor.setOverwrite(true);
|
||||
editor.keyBinding.$data.buffer = "";
|
||||
editor.keyBinding.$data.vimState = "start";
|
||||
this.onVisualMode = false;
|
||||
this.onVisualLineMode = false;
|
||||
editor._emit("changeStatus");
|
||||
// Save recorded keystrokes
|
||||
if (editor.commands.recording) {
|
||||
editor.commands.toggleRecording(editor);
|
||||
return editor.commands.macro;
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
visualMode: function(editor, lineMode) {
|
||||
if (
|
||||
(this.onVisualLineMode && lineMode)
|
||||
|| (this.onVisualMode && !lineMode)
|
||||
) {
|
||||
this.normalMode(editor);
|
||||
return;
|
||||
}
|
||||
|
||||
editor.setStyle('insert-mode');
|
||||
editor.unsetStyle('normal-mode');
|
||||
|
||||
editor._emit("changeStatus");
|
||||
if (lineMode) {
|
||||
this.onVisualLineMode = true;
|
||||
} else {
|
||||
this.onVisualMode = true;
|
||||
this.onVisualLineMode = false;
|
||||
}
|
||||
},
|
||||
getRightNthChar: function(editor, cursor, ch, n) {
|
||||
var line = editor.getSession().getLine(cursor.row);
|
||||
var matches = line.substr(cursor.column + 1).split(ch);
|
||||
|
||||
return n < matches.length ? matches.slice(0, n).join(ch).length : null;
|
||||
},
|
||||
getLeftNthChar: function(editor, cursor, ch, n) {
|
||||
var line = editor.getSession().getLine(cursor.row);
|
||||
var matches = line.substr(0, cursor.column).split(ch);
|
||||
|
||||
return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
|
||||
},
|
||||
toRealChar: function(ch) {
|
||||
if (ch.length === 1)
|
||||
return ch;
|
||||
|
||||
if (/^shift-./.test(ch))
|
||||
return ch[ch.length - 1].toUpperCase();
|
||||
else
|
||||
return "";
|
||||
},
|
||||
copyLine: function(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
editor.selection.moveTo(pos.row, pos.column);
|
||||
editor.selection.selectLine();
|
||||
registers._default.isLine = true;
|
||||
registers._default.text = editor.getCopyText().replace(/\n$/, "");
|
||||
editor.selection.moveTo(pos.row, pos.column);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
@ -30,10 +30,13 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
exports.isDark = false;
|
||||
exports.cssClass = "ace-sqlserver";
|
||||
exports.cssText = require("../requirejs/text!./sqlserver.css");
|
||||
"never use strict";
|
||||
|
||||
module.exports = {
|
||||
_default: {
|
||||
text: "",
|
||||
isLine: false
|
||||
}
|
||||
};
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
});
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -195,15 +195,11 @@ var Cursor = function(parentEl) {
|
|||
}
|
||||
|
||||
var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
|
||||
|
||||
if (!this.drawCursor) {
|
||||
style.left = pixelPos.left + "px";
|
||||
style.top = pixelPos.top + "px";
|
||||
style.width = config.characterWidth + "px";
|
||||
style.height = config.lineHeight + "px";
|
||||
} else {
|
||||
this.drawCursor(style, pixelPos, config, selections[i], this.session);
|
||||
}
|
||||
|
||||
style.left = pixelPos.left + "px";
|
||||
style.top = pixelPos.top + "px";
|
||||
style.width = config.characterWidth + "px";
|
||||
style.height = config.lineHeight + "px";
|
||||
}
|
||||
while (this.cursors.length > cursorIndex)
|
||||
this.removeCursor();
|
||||
|
|
@ -215,8 +211,6 @@ var Cursor = function(parentEl) {
|
|||
this.$pixelPos = pixelPos;
|
||||
this.restartTimer();
|
||||
};
|
||||
|
||||
this.drawCursor = null;
|
||||
|
||||
this.$setOverwrite = function(overwrite) {
|
||||
if (overwrite != this.overwrite) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
|||
document.documentElement.appendChild(el);
|
||||
var w = el.getBoundingClientRect().width;
|
||||
if (w > 0 && w < 1)
|
||||
CHAR_COUNT = 50;
|
||||
CHAR_COUNT = 1;
|
||||
else
|
||||
CHAR_COUNT = 100;
|
||||
el.parentNode.removeChild(el);
|
||||
|
|
@ -82,9 +82,9 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
|||
|
||||
this.$setMeasureNodeStyles = function(style, isRoot) {
|
||||
style.width = style.height = "auto";
|
||||
style.left = style.top = "0px";
|
||||
style.left = style.top = "-100px";
|
||||
style.visibility = "hidden";
|
||||
style.position = "absolute";
|
||||
style.position = "fixed";
|
||||
style.whiteSpace = "pre";
|
||||
|
||||
if (useragent.isIE < 8) {
|
||||
|
|
@ -120,14 +120,14 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
|||
this.setPolling = function(val) {
|
||||
if (val) {
|
||||
this.$pollSizeChanges();
|
||||
} else if (this.$pollSizeChangesTimer) {
|
||||
clearInterval(this.$pollSizeChangesTimer);
|
||||
this.$pollSizeChangesTimer = 0;
|
||||
} else {
|
||||
if (this.$pollSizeChangesTimer)
|
||||
this.$pollSizeChangesTimer;
|
||||
}
|
||||
};
|
||||
|
||||
this.$measureSizes = function() {
|
||||
if (CHAR_COUNT === 50) {
|
||||
if (CHAR_COUNT === 1) {
|
||||
var rect = null;
|
||||
try {
|
||||
rect = this.$measureNode.getBoundingClientRect();
|
||||
|
|
@ -136,7 +136,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
|
|||
};
|
||||
var size = {
|
||||
height: rect.height,
|
||||
width: rect.width / CHAR_COUNT
|
||||
width: rect.width
|
||||
};
|
||||
} else {
|
||||
var size = {
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ var Gutter = function(parentEl) {
|
|||
if (this.session)
|
||||
this.session.removeEventListener("change", this.$updateAnnotations);
|
||||
this.session = session;
|
||||
if (session)
|
||||
session.on("change", this.$updateAnnotations);
|
||||
session.on("change", this.$updateAnnotations);
|
||||
};
|
||||
|
||||
this.addGutterDecoration = function(row, className){
|
||||
|
|
@ -100,14 +99,16 @@ var Gutter = function(parentEl) {
|
|||
}
|
||||
};
|
||||
|
||||
this.$updateAnnotations = function (delta) {
|
||||
this.$updateAnnotations = function (e) {
|
||||
if (!this.$annotations.length)
|
||||
return;
|
||||
var firstRow = delta.start.row;
|
||||
var len = delta.end.row - firstRow;
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
var firstRow = range.start.row;
|
||||
var len = range.end.row - firstRow;
|
||||
if (len === 0) {
|
||||
// do nothing
|
||||
} else if (delta.action == 'remove') {
|
||||
} else if (delta.action == "removeText" || delta.action == "removeLines") {
|
||||
this.$annotations.splice(firstRow, len + 1, null);
|
||||
} else {
|
||||
var args = new Array(len + 1);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue