Merge branch 'master' of github.com:mozilla/ace
Conflicts: Makefile.dryice.js build/ace-uncompressed.js build/ace.js support/dryice
This commit is contained in:
commit
a9e93ef6ba
104 changed files with 3669 additions and 13871 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Junk that could exist anywhere:
|
||||
.DS_Store
|
||||
*.swp
|
||||
|
|
@ -9,7 +8,8 @@
|
|||
.settings/
|
||||
.settings.xml
|
||||
.settings.xml.old
|
||||
.*.gz
|
||||
|
||||
# A handy place to put stuff that git should ignore:
|
||||
/ignore/
|
||||
|
||||
/build/
|
||||
|
|
|
|||
26
.gitmodules
vendored
26
.gitmodules
vendored
|
|
@ -1,27 +1,9 @@
|
|||
[submodule "tool/support/node-o3-xml"]
|
||||
path = tool/support/node-o3-xml
|
||||
url = git://github.com/ajaxorg/node-o3-xml.git
|
||||
[submodule "tool/support/async"]
|
||||
path = tool/support/async
|
||||
url = git://github.com/fjakobs/async.js.git
|
||||
[submodule "support/requirejs"]
|
||||
path = support/requirejs
|
||||
url = git://github.com/jrburke/requirejs.git
|
||||
[submodule "support/node-o3-xml"]
|
||||
path = support/node-o3-xml
|
||||
url = git://github.com/ajaxorg/node-o3-xml.git
|
||||
[submodule "support/async"]
|
||||
path = support/async
|
||||
url = git://github.com/fjakobs/async.js.git
|
||||
[submodule "support/jsdom"]
|
||||
path = support/jsdom
|
||||
url = git://github.com/tmpvar/jsdom.git
|
||||
[submodule "support/node-htmlparser"]
|
||||
path = support/node-htmlparser
|
||||
url = git://github.com/tautologistics/node-htmlparser.git
|
||||
[submodule "support/cockpit"]
|
||||
path = support/cockpit
|
||||
url = git://github.com/mozilla/cockpit.git
|
||||
[submodule "support/dryice"]
|
||||
path = support/dryice
|
||||
url = git://github.com/mozilla/dryice.git
|
||||
url = git://github.com/ajaxorg/cockpit.git
|
||||
[submodule "support/pilot"]
|
||||
path = support/pilot
|
||||
url = git://github.com/ajaxorg/pilot.git
|
||||
639
LICENSE
639
LICENSE
|
|
@ -1,165 +1,476 @@
|
|||
Licensed under the tri-license MPL/LGPL/GPL.
|
||||
|
||||
MOZILLA PUBLIC LICENSE
|
||||
Version 1.1
|
||||
|
||||
---------------
|
||||
|
||||
1. Definitions.
|
||||
|
||||
1.0.1. "Commercial Use" means distribution or otherwise making the
|
||||
Covered Code available to a third party.
|
||||
|
||||
1.1. "Contributor" means each entity that creates or contributes to
|
||||
the creation of Modifications.
|
||||
|
||||
1.2. "Contributor Version" means the combination of the Original
|
||||
Code, prior Modifications used by a Contributor, and the Modifications
|
||||
made by that particular Contributor.
|
||||
|
||||
1.3. "Covered Code" means the Original Code or Modifications or the
|
||||
combination of the Original Code and Modifications, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.4. "Electronic Distribution Mechanism" means a mechanism generally
|
||||
accepted in the software development community for the electronic
|
||||
transfer of data.
|
||||
|
||||
1.5. "Executable" means Covered Code in any form other than Source
|
||||
Code.
|
||||
|
||||
1.6. "Initial Developer" means the individual or entity identified
|
||||
as the Initial Developer in the Source Code notice required by Exhibit
|
||||
A.
|
||||
|
||||
1.7. "Larger Work" means a work which combines Covered Code or
|
||||
portions thereof with code not governed by the terms of this License.
|
||||
|
||||
1.8. "License" means this document.
|
||||
|
||||
1.8.1. "Licensable" means having the right to grant, to the maximum
|
||||
extent possible, whether at the time of the initial grant or
|
||||
subsequently acquired, any and all of the rights conveyed herein.
|
||||
|
||||
1.9. "Modifications" means any addition to or deletion from the
|
||||
substance or structure of either the Original Code or any previous
|
||||
Modifications. When Covered Code is released as a series of files, a
|
||||
Modification is:
|
||||
A. Any addition to or deletion from the contents of a file
|
||||
containing Original Code or previous Modifications.
|
||||
|
||||
B. Any new file that contains any part of the Original Code or
|
||||
previous Modifications.
|
||||
|
||||
1.10. "Original Code" means Source Code of computer software code
|
||||
which is described in the Source Code notice required by Exhibit A as
|
||||
Original Code, and which, at the time of its release under this
|
||||
License is not already Covered Code governed by this License.
|
||||
|
||||
1.10.1. "Patent Claims" means any patent claim(s), now owned or
|
||||
hereafter acquired, including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by grantor.
|
||||
|
||||
1.11. "Source Code" means the preferred form of the Covered Code for
|
||||
making modifications to it, including all modules it contains, plus
|
||||
any associated interface definition files, scripts used to control
|
||||
compilation and installation of an Executable, or source code
|
||||
differential comparisons against either the Original Code or another
|
||||
well known, available Covered Code of the Contributor's choice. The
|
||||
Source Code can be in a compressed or archival form, provided the
|
||||
appropriate decompression or de-archiving software is widely available
|
||||
for no charge.
|
||||
|
||||
1.12. "You" (or "Your") means an individual or a legal entity
|
||||
exercising rights under, and complying with all of the terms of, this
|
||||
License or a future version of this License issued under Section 6.1.
|
||||
For legal entities, "You" includes any entity which controls, is
|
||||
controlled by, or is under common control with You. For purposes of
|
||||
this definition, "control" means (a) the power, direct or indirect,
|
||||
to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (b) ownership of more than fifty percent
|
||||
(50%) of the outstanding shares or beneficial ownership of such
|
||||
entity.
|
||||
|
||||
2. Source Code License.
|
||||
|
||||
2.1. The Initial Developer Grant.
|
||||
The Initial Developer hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license, subject to third party intellectual property
|
||||
claims:
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Initial Developer to use, reproduce,
|
||||
modify, display, perform, sublicense and distribute the Original
|
||||
Code (or portions thereof) with or without Modifications, and/or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patents Claims infringed by the making, using or
|
||||
selling of Original Code, to make, have made, use, practice,
|
||||
sell, and offer for sale, and/or otherwise dispose of the
|
||||
Original Code (or portions thereof).
|
||||
|
||||
(c) the licenses granted in this Section 2.1(a) and (b) are
|
||||
effective on the date Initial Developer first distributes
|
||||
Original Code under the terms of this License.
|
||||
|
||||
(d) Notwithstanding Section 2.1(b) above, no patent license is
|
||||
granted: 1) for code that You delete from the Original Code; 2)
|
||||
separate from the Original Code; or 3) for infringements caused
|
||||
by: i) the modification of the Original Code or ii) the
|
||||
combination of the Original Code with other software or devices.
|
||||
|
||||
2.2. Contributor Grant.
|
||||
Subject to third party intellectual property claims, each Contributor
|
||||
hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Contributor, to use, reproduce, modify,
|
||||
display, perform, sublicense and distribute the Modifications
|
||||
created by such Contributor (or portions thereof) either on an
|
||||
unmodified basis, with other Modifications, as Covered Code
|
||||
and/or as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims infringed by the making, using, or
|
||||
selling of Modifications made by that Contributor either alone
|
||||
and/or in combination with its Contributor Version (or portions
|
||||
of such combination), to make, use, sell, offer for sale, have
|
||||
made, and/or otherwise dispose of: 1) Modifications made by that
|
||||
Contributor (or portions thereof); and 2) the combination of
|
||||
Modifications made by that Contributor with its Contributor
|
||||
Version (or portions of such combination).
|
||||
|
||||
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
|
||||
effective on the date Contributor first makes Commercial Use of
|
||||
the Covered Code.
|
||||
|
||||
(d) Notwithstanding Section 2.2(b) above, no patent license is
|
||||
granted: 1) for any code that Contributor has deleted from the
|
||||
Contributor Version; 2) separate from the Contributor Version;
|
||||
3) for infringements caused by: i) third party modifications of
|
||||
Contributor Version or ii) the combination of Modifications made
|
||||
by that Contributor with other software (except as part of the
|
||||
Contributor Version) or other devices; or 4) under Patent Claims
|
||||
infringed by Covered Code in the absence of Modifications made by
|
||||
that Contributor.
|
||||
|
||||
3. Distribution Obligations.
|
||||
|
||||
3.1. Application of License.
|
||||
The Modifications which You create or to which You contribute are
|
||||
governed by the terms of this License, including without limitation
|
||||
Section 2.2. The Source Code version of Covered Code may be
|
||||
distributed only under the terms of this License or a future version
|
||||
of this License released under Section 6.1, and You must include a
|
||||
copy of this License with every copy of the Source Code You
|
||||
distribute. You may not offer or impose any terms on any Source Code
|
||||
version that alters or restricts the applicable version of this
|
||||
License or the recipients' rights hereunder. However, You may include
|
||||
an additional document offering the additional rights described in
|
||||
Section 3.5.
|
||||
|
||||
3.2. Availability of Source Code.
|
||||
Any Modification which You create or to which You contribute must be
|
||||
made available in Source Code form under the terms of this License
|
||||
either on the same media as an Executable version or via an accepted
|
||||
Electronic Distribution Mechanism to anyone to whom you made an
|
||||
Executable version available; and if made available via Electronic
|
||||
Distribution Mechanism, must remain available for at least twelve (12)
|
||||
months after the date it initially became available, or at least six
|
||||
(6) months after a subsequent version of that particular Modification
|
||||
has been made available to such recipients. You are responsible for
|
||||
ensuring that the Source Code version remains available even if the
|
||||
Electronic Distribution Mechanism is maintained by a third party.
|
||||
|
||||
3.3. Description of Modifications.
|
||||
You must cause all Covered Code to which You contribute to contain a
|
||||
file documenting the changes You made to create that Covered Code and
|
||||
the date of any change. You must include a prominent statement that
|
||||
the Modification is derived, directly or indirectly, from Original
|
||||
Code provided by the Initial Developer and including the name of the
|
||||
Initial Developer in (a) the Source Code, and (b) in any notice in an
|
||||
Executable version or related documentation in which You describe the
|
||||
origin or ownership of the Covered Code.
|
||||
|
||||
3.4. Intellectual Property Matters
|
||||
(a) Third Party Claims.
|
||||
If Contributor has knowledge that a license under a third party's
|
||||
intellectual property rights is required to exercise the rights
|
||||
granted by such Contributor under Sections 2.1 or 2.2,
|
||||
Contributor must include a text file with the Source Code
|
||||
distribution titled "LEGAL" which describes the claim and the
|
||||
party making the claim in sufficient detail that a recipient will
|
||||
know whom to contact. If Contributor obtains such knowledge after
|
||||
the Modification is made available as described in Section 3.2,
|
||||
Contributor shall promptly modify the LEGAL file in all copies
|
||||
Contributor makes available thereafter and shall take other steps
|
||||
(such as notifying appropriate mailing lists or newsgroups)
|
||||
reasonably calculated to inform those who received the Covered
|
||||
Code that new knowledge has been obtained.
|
||||
|
||||
(b) Contributor APIs.
|
||||
If Contributor's Modifications include an application programming
|
||||
interface and Contributor has knowledge of patent licenses which
|
||||
are reasonably necessary to implement that API, Contributor must
|
||||
also include this information in the LEGAL file.
|
||||
|
||||
(c) Representations.
|
||||
Contributor represents that, except as disclosed pursuant to
|
||||
Section 3.4(a) above, Contributor believes that Contributor's
|
||||
Modifications are Contributor's original creation(s) and/or
|
||||
Contributor has sufficient rights to grant the rights conveyed by
|
||||
this License.
|
||||
|
||||
3.5. Required Notices.
|
||||
You must duplicate the notice in Exhibit A in each file of the Source
|
||||
Code. If it is not possible to put such notice in a particular Source
|
||||
Code file due to its structure, then You must include such notice in a
|
||||
location (such as a relevant directory) where a user would be likely
|
||||
to look for such a notice. If You created one or more Modification(s)
|
||||
You may add your name as a Contributor to the notice described in
|
||||
Exhibit A. You must also duplicate this License in any documentation
|
||||
for the Source Code where You describe recipients' rights or ownership
|
||||
rights relating to Covered Code. You may choose to offer, and to
|
||||
charge a fee for, warranty, support, indemnity or liability
|
||||
obligations to one or more recipients of Covered Code. However, You
|
||||
may do so only on Your own behalf, and not on behalf of the Initial
|
||||
Developer or any Contributor. You must make it absolutely clear than
|
||||
any such warranty, support, indemnity or liability obligation is
|
||||
offered by You alone, and You hereby agree to indemnify the Initial
|
||||
Developer and every Contributor for any liability incurred by the
|
||||
Initial Developer or such Contributor as a result of warranty,
|
||||
support, indemnity or liability terms You offer.
|
||||
|
||||
3.6. Distribution of Executable Versions.
|
||||
You may distribute Covered Code in Executable form only if the
|
||||
requirements of Section 3.1-3.5 have been met for that Covered Code,
|
||||
and if You include a notice stating that the Source Code version of
|
||||
the Covered Code is available under the terms of this License,
|
||||
including a description of how and where You have fulfilled the
|
||||
obligations of Section 3.2. The notice must be conspicuously included
|
||||
in any notice in an Executable version, related documentation or
|
||||
collateral in which You describe recipients' rights relating to the
|
||||
Covered Code. You may distribute the Executable version of Covered
|
||||
Code or ownership rights under a license of Your choice, which may
|
||||
contain terms different from this License, provided that You are in
|
||||
compliance with the terms of this License and that the license for the
|
||||
Executable version does not attempt to limit or alter the recipient's
|
||||
rights in the Source Code version from the rights set forth in this
|
||||
License. If You distribute the Executable version under a different
|
||||
license You must make it absolutely clear that any terms which differ
|
||||
from this License are offered by You alone, not by the Initial
|
||||
Developer or any Contributor. You hereby agree to indemnify the
|
||||
Initial Developer and every Contributor for any liability incurred by
|
||||
the Initial Developer or such Contributor as a result of any such
|
||||
terms You offer.
|
||||
|
||||
3.7. Larger Works.
|
||||
You may create a Larger Work by combining Covered Code with other code
|
||||
not governed by the terms of this License and distribute the Larger
|
||||
Work as a single product. In such a case, You must make sure the
|
||||
requirements of this License are fulfilled for the Covered Code.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation.
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Code due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description
|
||||
must be included in the LEGAL file described in Section 3.4 and must
|
||||
be included with all distributions of the Source Code. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
5. Application of this License.
|
||||
|
||||
This License applies to code to which the Initial Developer has
|
||||
attached the notice in Exhibit A and to related Covered Code.
|
||||
|
||||
6. Versions of the License.
|
||||
|
||||
6.1. New Versions.
|
||||
Netscape Communications Corporation ("Netscape") may publish revised
|
||||
and/or new versions of the License from time to time. Each version
|
||||
will be given a distinguishing version number.
|
||||
|
||||
6.2. Effect of New Versions.
|
||||
Once Covered Code has been published under a particular version of the
|
||||
License, You may always continue to use it under the terms of that
|
||||
version. You may also choose to use such Covered Code under the terms
|
||||
of any subsequent version of the License published by Netscape. No one
|
||||
other than Netscape has the right to modify the terms applicable to
|
||||
Covered Code created under this License.
|
||||
|
||||
6.3. Derivative Works.
|
||||
If You create or use a modified version of this License (which you may
|
||||
only do in order to apply it to code which is not already Covered Code
|
||||
governed by this License), You must (a) rename Your license so that
|
||||
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
|
||||
"MPL", "NPL" or any confusingly similar phrase do not appear in your
|
||||
license (except to note that your license differs from this License)
|
||||
and (b) otherwise make it clear that Your version of the license
|
||||
contains terms which differ from the Mozilla Public License and
|
||||
Netscape Public License. (Filling in the name of the Initial
|
||||
Developer, Original Code or Contributor in the notice described in
|
||||
Exhibit A shall not of themselves be deemed to be modifications of
|
||||
this License.)
|
||||
|
||||
7. DISCLAIMER OF WARRANTY.
|
||||
|
||||
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
|
||||
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
|
||||
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
|
||||
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
|
||||
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
|
||||
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
|
||||
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||
|
||||
8. TERMINATION.
|
||||
|
||||
8.1. This License and the rights granted hereunder will terminate
|
||||
automatically if You fail to comply with terms herein and fail to cure
|
||||
such breach within 30 days of becoming aware of the breach. All
|
||||
sublicenses to the Covered Code which are properly granted shall
|
||||
survive any termination of this License. Provisions which, by their
|
||||
nature, must remain in effect beyond the termination of this License
|
||||
shall survive.
|
||||
|
||||
8.2. If You initiate litigation by asserting a patent infringement
|
||||
claim (excluding declatory judgment actions) against Initial Developer
|
||||
or a Contributor (the Initial Developer or Contributor against whom
|
||||
You file such action is referred to as "Participant") alleging that:
|
||||
|
||||
(a) such Participant's Contributor Version directly or indirectly
|
||||
infringes any patent, then any and all rights granted by such
|
||||
Participant to You under Sections 2.1 and/or 2.2 of this License
|
||||
shall, upon 60 days notice from Participant terminate prospectively,
|
||||
unless if within 60 days after receipt of notice You either: (i)
|
||||
agree in writing to pay Participant a mutually agreeable reasonable
|
||||
royalty for Your past and future use of Modifications made by such
|
||||
Participant, or (ii) withdraw Your litigation claim with respect to
|
||||
the Contributor Version against such Participant. If within 60 days
|
||||
of notice, a reasonable royalty and payment arrangement are not
|
||||
mutually agreed upon in writing by the parties or the litigation claim
|
||||
is not withdrawn, the rights granted by Participant to You under
|
||||
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
|
||||
the 60 day notice period specified above.
|
||||
|
||||
(b) any software, hardware, or device, other than such Participant's
|
||||
Contributor Version, directly or indirectly infringes any patent, then
|
||||
any rights granted to You by such Participant under Sections 2.1(b)
|
||||
and 2.2(b) are revoked effective as of the date You first made, used,
|
||||
sold, distributed, or had made, Modifications made by that
|
||||
Participant.
|
||||
|
||||
8.3. If You assert a patent infringement claim against Participant
|
||||
alleging that such Participant's Contributor Version directly or
|
||||
indirectly infringes any patent where such claim is resolved (such as
|
||||
by license or settlement) prior to the initiation of patent
|
||||
infringement litigation, then the reasonable value of the licenses
|
||||
granted by such Participant under Sections 2.1 or 2.2 shall be taken
|
||||
into account in determining the amount or value of any payment or
|
||||
license.
|
||||
|
||||
8.4. In the event of termination under Sections 8.1 or 8.2 above,
|
||||
all end user license agreements (excluding distributors and resellers)
|
||||
which have been validly granted by You or any distributor hereunder
|
||||
prior to termination shall survive termination.
|
||||
|
||||
9. LIMITATION OF LIABILITY.
|
||||
|
||||
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
|
||||
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
|
||||
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
|
||||
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
|
||||
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
|
||||
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
|
||||
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
|
||||
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
|
||||
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
|
||||
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
|
||||
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
|
||||
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
10. U.S. GOVERNMENT END USERS.
|
||||
|
||||
The Covered Code is a "commercial item," as that term is defined in
|
||||
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
|
||||
software" and "commercial computer software documentation," as such
|
||||
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
|
||||
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
|
||||
all U.S. Government End Users acquire Covered Code with only those
|
||||
rights set forth herein.
|
||||
|
||||
11. MISCELLANEOUS.
|
||||
|
||||
This License represents the complete agreement concerning subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. This License shall be governed by
|
||||
California law provisions (except to the extent applicable law, if
|
||||
any, provides otherwise), excluding its conflict-of-law provisions.
|
||||
With respect to disputes in which at least one party is a citizen of,
|
||||
or an entity chartered or registered to do business in the United
|
||||
States of America, any litigation relating to this License shall be
|
||||
subject to the jurisdiction of the Federal Courts of the Northern
|
||||
District of California, with venue lying in Santa Clara County,
|
||||
California, with the losing party responsible for costs, including
|
||||
without limitation, court costs and reasonable attorneys' fees and
|
||||
expenses. The application of the United Nations Convention on
|
||||
Contracts for the International Sale of Goods is expressly excluded.
|
||||
Any law or regulation which provides that the language of a contract
|
||||
shall be construed against the drafter shall not apply to this
|
||||
License.
|
||||
|
||||
12. RESPONSIBILITY FOR CLAIMS.
|
||||
|
||||
As between Initial Developer and the Contributors, each party is
|
||||
responsible for claims and damages arising, directly or indirectly,
|
||||
out of its utilization of rights under this License and You agree to
|
||||
work with Initial Developer and Contributors to distribute such
|
||||
responsibility on an equitable basis. Nothing herein is intended or
|
||||
shall be deemed to constitute any admission of liability.
|
||||
|
||||
13. MULTIPLE-LICENSED CODE.
|
||||
|
||||
Initial Developer may designate portions of the Covered Code as
|
||||
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
|
||||
Developer permits you to utilize portions of the Covered Code under
|
||||
Your choice of the NPL or the alternative licenses, if any, specified
|
||||
by the Initial Developer in the file described in Exhibit A.
|
||||
|
||||
EXHIBIT A -Mozilla Public License.
|
||||
|
||||
``The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is ______________________________________.
|
||||
|
||||
The Initial Developer of the Original Code is ________________________.
|
||||
Portions created by ______________________ are Copyright (C) ______
|
||||
_______________________. All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms
|
||||
of the _____ license (the "[___] License"), in which case the
|
||||
provisions of [______] License are applicable instead of those
|
||||
above. If you wish to allow use of your version of this file only
|
||||
under the terms of the [____] License and not to allow others to use
|
||||
your version of this file under the MPL, indicate your decision by
|
||||
deleting the provisions above and replace them with the notice and
|
||||
other provisions required by the [___] License. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file
|
||||
under either the MPL or the [___] License."
|
||||
|
||||
[NOTE: The text of this Exhibit A may differ slightly from the text of
|
||||
the notices in the Source Code files of the Original Code. You should
|
||||
use the text of this Exhibit A rather than the text found in the
|
||||
Original Code Source Code for Your Modifications.]
|
||||
|
||||
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
Version 3, 29 June 2007
|
||||
20
Makefile.dryice.js
Normal file → Executable file
20
Makefile.dryice.js
Normal file → Executable file
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env node
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
|
@ -14,7 +15,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -40,7 +41,7 @@ var copy = require('dryice').copy;
|
|||
var aceHome = __dirname;
|
||||
|
||||
var project = copy.createCommonJsProject([
|
||||
aceHome + '/support/cockpit/support/pilot/lib',
|
||||
aceHome + '/support/pilot/lib',
|
||||
aceHome + '/support/cockpit/lib',
|
||||
aceHome + '/lib',
|
||||
aceHome + '/demo'
|
||||
|
|
@ -103,7 +104,7 @@ console.log('---------');
|
|||
var pilot = copy.createDataObject();
|
||||
copy({
|
||||
source: {
|
||||
root: aceHome + '/support/cockpit/support/pilot/lib',
|
||||
root: aceHome + '/support/pilot/lib',
|
||||
include: /.*\.js$/,
|
||||
exclude: /tests?\//
|
||||
},
|
||||
|
|
@ -177,19 +178,26 @@ copy({
|
|||
var data = copy.createDataObject();
|
||||
copy({
|
||||
source: [
|
||||
'demo/mini_require.js',
|
||||
'build_support/mini_require.js',
|
||||
pilot,
|
||||
// cockpit,
|
||||
ace,
|
||||
'demo/build_boot.js'
|
||||
'build_support/boot.js'
|
||||
],
|
||||
dest: data
|
||||
});
|
||||
|
||||
copy({
|
||||
source: [
|
||||
'build_support/editor.html'
|
||||
],
|
||||
dest: 'build/editor.html'
|
||||
});
|
||||
|
||||
// Create the compressed and uncompressed output files
|
||||
copy({
|
||||
source: data,
|
||||
filter: copy.filter.uglifyjs,
|
||||
//filter: copy.filter.uglifyjs,
|
||||
dest: 'build/ace.js'
|
||||
});
|
||||
copy({
|
||||
|
|
|
|||
72
Readme.md
72
Readme.md
|
|
@ -1,6 +1,70 @@
|
|||
ACE (Ajax.org Code Editor)
|
||||
==========================
|
||||
Ace (Ajax.org Cloud9 Editor)
|
||||
============================
|
||||
|
||||
ACE is a standalone code editor written in JavaScript. It can be easily embedded in any web page and JavaScript application. It is currently used as the editor component of the [Cloud9 IDE](http://cloud9ide.com).
|
||||
Ace is a standalone code editor written in JavaScript. Our goal is to create a web based code editor that matches and extends the features, usability and performance of existing native editors such as TextMate, Vim or Eclipse. It can be easily embedded in any web page and JavaScript application. Ace is developed as the primary editor for [Cloud9 IDE](http://www.cloud9ide.com/) and the successor of the Mozilla Skywriter (Bespin) Project.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Syntax highlighting
|
||||
* Auto indentation and outdent
|
||||
* An optional command line
|
||||
* Work with huge documents (100,000 lines and more are no problem)
|
||||
* Fully customizable key bindings including VI and Emacs modes
|
||||
* Themes (TextMate themes can be imported)
|
||||
* Search and replace with regular expressions
|
||||
* Highlight matching parentheses
|
||||
* Toggle between soft tabs and real tabs
|
||||
* Displays hidden characters
|
||||
|
||||
Take Ace for a spin!
|
||||
--------------------
|
||||
|
||||
Check out the Ace live [demo](http://ajaxorg.github.com/ace/editor-build.html) or get a [Cloud9 IDE account](http://run.cloud9ide.com) to experience Ace while editing one of your own GitHub projects.
|
||||
|
||||
History
|
||||
-------
|
||||
|
||||
Previously known as “Bespin” or lately “Skywriter” it’s now known as Ace (Ajax.org Cloud9 Editor)! Bespin and Ace started as two independent projects both aiming to build a no compromise code editor component for the web. Bespin started as part of Mozilla Labs and was based on the canvas tag, while Ace is the Editor component of the Cloud9 IDE and is using the DOM for rendering. After the release of Ace at JSConf.eu 2010 in Berlin the Skywriter team decided to merge Ace with a simplified version of Skywriter's plugin system and some of Skywriter's extensibility points. All these changes have been merged back to Ace now, which supersedes Skywriter. Both Ajax.org and Mozilla are actively developing and maintaining Ace.
|
||||
|
||||
Getting the code
|
||||
----------------
|
||||
|
||||
Ace is a community project. We actively encourage and support contributions. The Ace source code is hosted on GitHub. It is released under the Mozilla tri-license (MPL/GPL/LGPL). This is the same license used by Firefox. This license is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings!
|
||||
|
||||
git clone git://github.com/ajaxorg/ace.git
|
||||
git submodule update --init --recursive
|
||||
|
||||
Running Ace
|
||||
-----------
|
||||
|
||||
After the checkout Ace works out of the box. No build step is required. Simply open 'editor.html' in any browser except Google Chrome. Google Chrome doesn't allow XMLHTTPRequests from files loaded from disc (i.e. with a file:/// URL). To open the Ace in Chrome simply start the bundled mini HTTP server:
|
||||
|
||||
./static.py
|
||||
|
||||
The editor can then be opened at http://localhost:9999/editor.html.
|
||||
|
||||
Package Ace
|
||||
-----------
|
||||
|
||||
To package Ace we use the dryice build tool developed by the Mozilla Skywriter team. To install dryice and all its dependencies simply call:
|
||||
|
||||
npm link .
|
||||
|
||||
Afterwards Ace can by build by calling
|
||||
|
||||
./Makefile.dryice.js
|
||||
|
||||
The packaged Ace will be put in the 'build' folder.
|
||||
|
||||
Running the Unit Tests
|
||||
----------------------
|
||||
|
||||
The Ace unit tests run on node.js. Before the first run a couple of node mudules have to be installed. The easiest way to do this is by using the node package manager (npm). In the Ace base directory simply call
|
||||
|
||||
npm link .
|
||||
|
||||
To run the tests call:
|
||||
|
||||
node lib/ace/test/all.js
|
||||
|
||||
Checkout the [demo](http://ajaxorg.github.com/ace/editor.html)!
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -51,23 +51,25 @@ var ace = {
|
|||
var env = require("pilot/environment").create();
|
||||
var catalog = require("pilot/plugin_manager").catalog;
|
||||
catalog.startupPlugins({ env: env }).then(function() {
|
||||
var Document = require("ace/document").Document;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
var Editor = require("ace/editor").Editor;
|
||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||
var theme = require("ace/theme/textmate");
|
||||
|
||||
var doc = new Document(el.innerHTML);
|
||||
var doc = new EditSession(el.innerHTML);
|
||||
el.innerHTML = '';
|
||||
doc.setMode(new JavaScriptMode());
|
||||
doc.setUndoManager(new UndoManager());
|
||||
env.document = doc;
|
||||
env.editor = new Editor(new Renderer(el, theme));
|
||||
env.editor.setDocument(doc);
|
||||
env.editor.setSession(doc);
|
||||
env.editor.resize();
|
||||
window.addEventListener("resize", function() {
|
||||
env.editor.resize();
|
||||
}, false);
|
||||
el.env = env;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -87,6 +87,6 @@ function define(module, payload) {
|
|||
return;
|
||||
}
|
||||
|
||||
console.log('defining module: ' + module + ' as a ' + typeof payload);
|
||||
// console.log('defining module: ' + module + ' as a ' + typeof payload);
|
||||
require.modules[module] = payload;
|
||||
}
|
||||
22
demo/boot.js
22
demo/boot.js
|
|
@ -36,22 +36,16 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var config = {
|
||||
packagePaths: {
|
||||
"../lib": [
|
||||
{ name:"ace", lib: "." }
|
||||
],
|
||||
"../support/cockpit/lib": [
|
||||
{ name: "cockpit", main: "index", lib: "." }
|
||||
],
|
||||
"../support/cockpit/support/pilot/lib": [
|
||||
{ name: "pilot", main: "index", lib: "." }
|
||||
]
|
||||
},
|
||||
paths: { demo_startup: "../demo/demo_startup" }
|
||||
paths: {
|
||||
demo: "../demo",
|
||||
ace: "../lib/ace",
|
||||
cockpit: "../support/cockpit/lib/cockpit",
|
||||
pilot: "../support/pilot/lib/pilot"
|
||||
}
|
||||
};
|
||||
|
||||
var deps = [ "pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings",
|
||||
"pilot/environment", "demo_startup" ];
|
||||
"pilot/environment", "demo/startup" ];
|
||||
|
||||
require(config);
|
||||
require(deps, function() {
|
||||
|
|
@ -59,7 +53,7 @@ require(deps, function() {
|
|||
catalog.registerPlugins([ "pilot/index", "cockpit/index" ]).then(function() {
|
||||
var env = require("pilot/environment").create();
|
||||
catalog.startupPlugins({ env: env }).then(function() {
|
||||
require("demo_startup").launch(env);
|
||||
require("demo/startup").launch(env);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ exports.launch = function(env) {
|
|||
var event = require("pilot/event");
|
||||
var Editor = require("ace/editor").Editor;
|
||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||
var theme = require("ace/theme/textmate");
|
||||
var Document = require("ace/document").Document;
|
||||
var theme = require("ace/theme/textmate");
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
var CssMode = require("ace/mode/css").Mode;
|
||||
var HtmlMode = require("ace/mode/html").Mode;
|
||||
|
|
@ -55,37 +55,73 @@ exports.launch = function(env) {
|
|||
var TextMode = require("ace/mode/text").Mode;
|
||||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
|
||||
var vim = require("ace/keyboard/keybinding/vim").Vim;
|
||||
var emacs = require("ace/keyboard/keybinding/emacs").Emacs;
|
||||
var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
|
||||
|
||||
var docs = {};
|
||||
|
||||
docs.js = new Document(document.getElementById("jstext").innerHTML);
|
||||
docs.js = new EditSession(document.getElementById("jstext").innerHTML);
|
||||
docs.js.setMode(new JavaScriptMode());
|
||||
docs.js.setUndoManager(new UndoManager());
|
||||
|
||||
docs.css = new Document(document.getElementById("csstext").innerHTML);
|
||||
docs.css = new EditSession(document.getElementById("csstext").innerHTML);
|
||||
docs.css.setMode(new CssMode());
|
||||
docs.css.setUndoManager(new UndoManager());
|
||||
|
||||
docs.html = new Document(document.getElementById("htmltext").innerHTML);
|
||||
docs.html = new EditSession(document.getElementById("htmltext").innerHTML);
|
||||
docs.html.setMode(new HtmlMode());
|
||||
docs.html.setUndoManager(new UndoManager());
|
||||
|
||||
docs.python = new Document(document.getElementById("pythontext").innerHTML);
|
||||
docs.python = new EditSession(document.getElementById("pythontext").innerHTML);
|
||||
docs.python.setMode(new PythonMode());
|
||||
docs.python.setUndoManager(new UndoManager());
|
||||
|
||||
docs.php = new Document(document.getElementById("phptext").innerHTML);
|
||||
docs.php = new EditSession(document.getElementById("phptext").innerHTML);
|
||||
docs.php.setMode(new PhpMode());
|
||||
docs.php.setUndoManager(new UndoManager());
|
||||
|
||||
var docEl = document.getElementById("doc");
|
||||
|
||||
var container = document.getElementById("editor");
|
||||
env.editor = new Editor(new Renderer(container, theme));
|
||||
|
||||
var modes = {
|
||||
text: new TextMode(),
|
||||
xml: new XmlMode(),
|
||||
html: new HtmlMode(),
|
||||
css: new CssMode(),
|
||||
javascript: new JavaScriptMode(),
|
||||
python: new PythonMode(),
|
||||
php: new PhpMode()
|
||||
};
|
||||
|
||||
function getMode() {
|
||||
return modes[modeEl.value];
|
||||
}
|
||||
|
||||
|
||||
var modeEl = document.getElementById("mode");
|
||||
function setMode() {
|
||||
env.editor.getSession().setMode(modes[modeEl.value] || modes.text);
|
||||
}
|
||||
modeEl.onchange = setMode;
|
||||
setMode();
|
||||
|
||||
// This is how you can set a custom keyboardHandler.
|
||||
//
|
||||
// Define some basic keymapping using a hash:
|
||||
// env.editor.setKeyboardHandler(new HashHandler({
|
||||
// "gotoright": "Tab"
|
||||
// }));
|
||||
//
|
||||
// Use a more complex keymapping:
|
||||
// env.editor.setKeyboardHandler(vim);
|
||||
|
||||
var docEl = document.getElementById("doc");
|
||||
function onDocChange() {
|
||||
var doc = getDoc();
|
||||
env.editor.setDocument(doc);
|
||||
|
||||
var doc = docs[docEl.value];
|
||||
env.editor.setSession(doc);
|
||||
|
||||
var mode = doc.getMode();
|
||||
if (mode instanceof JavaScriptMode) {
|
||||
modeEl.value = "javascript";
|
||||
|
|
@ -108,55 +144,50 @@ exports.launch = function(env) {
|
|||
else {
|
||||
modeEl.value = "text";
|
||||
}
|
||||
|
||||
|
||||
env.editor.focus();
|
||||
}
|
||||
docEl.onchange = onDocChange;
|
||||
onDocChange();
|
||||
|
||||
function getDoc() {
|
||||
return docs[docEl.value];
|
||||
}
|
||||
|
||||
var modeEl = document.getElementById("mode");
|
||||
modeEl.onchange = function() {
|
||||
env.editor.getDocument().setMode(modes[modeEl.value] || modes.text);
|
||||
};
|
||||
|
||||
var modes = {
|
||||
text: new TextMode(),
|
||||
xml: new XmlMode(),
|
||||
html: new HtmlMode(),
|
||||
css: new CssMode(),
|
||||
javascript: new JavaScriptMode(),
|
||||
python: new PythonMode(),
|
||||
php: new PhpMode()
|
||||
};
|
||||
|
||||
function getMode() {
|
||||
return modes[modeEl.value];
|
||||
}
|
||||
|
||||
var themeEl = document.getElementById("theme");
|
||||
themeEl.onchange = function() {
|
||||
function setTheme() {
|
||||
env.editor.setTheme(themeEl.value);
|
||||
};
|
||||
themeEl.onchange = setTheme;
|
||||
setTheme();
|
||||
|
||||
|
||||
var selectEl = document.getElementById("select_style");
|
||||
selectEl.onchange = function() {
|
||||
function setSelectionStyle() {
|
||||
if (selectEl.checked) {
|
||||
env.editor.setSelectionStyle("line");
|
||||
} else {
|
||||
env.editor.setSelectionStyle("text");
|
||||
}
|
||||
};
|
||||
selectEl.onclick = setSelectionStyle;
|
||||
setSelectionStyle();
|
||||
|
||||
|
||||
var activeEl = document.getElementById("highlight_active");
|
||||
activeEl.onchange = function() {
|
||||
function setHighlightActiveLine() {
|
||||
env.editor.setHighlightActiveLine(!!activeEl.checked);
|
||||
};
|
||||
activeEl.onclick = setHighlightActiveLine;
|
||||
setHighlightActiveLine();
|
||||
|
||||
onDocChange();
|
||||
|
||||
var showHiddenEl = document.getElementById("show_hidden");
|
||||
function setShowInvisibles() {
|
||||
env.editor.setShowInvisibles(!!showHiddenEl.checked);
|
||||
};
|
||||
showHiddenEl.onclick = setShowInvisibles;
|
||||
setShowInvisibles();
|
||||
|
||||
|
||||
// for debugging
|
||||
window.jump = function() {
|
||||
var jump = document.getElementById("jump");
|
||||
var cursor = env.editor.getCursorPosition();
|
||||
|
|
@ -209,7 +240,7 @@ exports.launch = function(env) {
|
|||
env.editor.onTextInput(reader.result);
|
||||
|
||||
modeEl.value = mode;
|
||||
env.editor.getDocument().setMode(modes[mode]);
|
||||
env.editor.getSession().setMode(modes[mode]);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<node CREATED="1271052825952" ID="Freemind_Link_622561431" MODIFIED="1271052828013" TEXT="qooxdoo"/>
|
||||
<node CREATED="1271052830859" ID="Freemind_Link_18779066" MODIFIED="1271052833496" TEXT="APF!"/>
|
||||
</node>
|
||||
<node CREATED="1271052839079" ID="Freemind_Link_439583810" MODIFIED="1271052852530" TEXT="Options">
|
||||
<node CREATED="1271052839079" FOLDED="true" ID="Freemind_Link_439583810" MODIFIED="1271052852530" TEXT="Options">
|
||||
<node CREATED="1271052853166" ID="Freemind_Link_629899491" MODIFIED="1271052860101" TEXT="Tabs to spaces"/>
|
||||
<node CREATED="1271052862867" ID="Freemind_Link_746641062" MODIFIED="1271052866129" TEXT="Spaces to tabs"/>
|
||||
<node CREATED="1271052866517" ID="Freemind_Link_192666733" MODIFIED="1271052869210" TEXT="tab width"/>
|
||||
|
|
@ -50,8 +50,13 @@
|
|||
<node CREATED="1271052900934" ID="Freemind_Link_62594174" MODIFIED="1271052907981" TEXT="comment block"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1295094741432" ID="Freemind_Link_1547780849" MODIFIED="1295094754462" TEXT="shadow doc synced in web worker">
|
||||
<node CREATED="1295094757135" ID="Freemind_Link_1288894358" MODIFIED="1295094769539" TEXT="do computation intensive stuff in a worker"/>
|
||||
<node CREATED="1295094772327" ID="Freemind_Link_294024951" MODIFIED="1295094784554" TEXT="all operation >= O(n)"/>
|
||||
<node CREATED="1295265748917" ID="Freemind_Link_730092876" MODIFIED="1295265754848" TEXT="jslint in worker"/>
|
||||
</node>
|
||||
<node CREATED="1271061753644" ID="Freemind_Link_1898747747" MODIFIED="1271061761714" POSITION="left" TEXT="Competition">
|
||||
</node>
|
||||
<node CREATED="1271061753644" FOLDED="true" ID="Freemind_Link_1898747747" MODIFIED="1271061761714" POSITION="left" TEXT="Competition">
|
||||
<node CREATED="1271061762151" ID="Freemind_Link_248244633" MODIFIED="1271061764275" TEXT="bespin"/>
|
||||
<node CREATED="1271061764616" ID="Freemind_Link_1186004994" MODIFIED="1271061768509" TEXT="codeMirror"/>
|
||||
<node CREATED="1271061780744" ID="Freemind_Link_457888774" LINK="http://www.cdolivet.com/index.php?page=editArea" MODIFIED="1271061808808" TEXT="editarea"/>
|
||||
|
|
|
|||
207
editor-build.html
Normal file
207
editor-build.html
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Editor</title>
|
||||
<meta name="author" content="Fabian Jakobs">
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
font-family: Arial, Helvetica, sans-serif, Tahoma, Verdana, sans-serif;
|
||||
font-size: 12px;
|
||||
background: rgb(14, 98, 165);
|
||||
color: white;
|
||||
}
|
||||
|
||||
#editor {
|
||||
top: 55px;
|
||||
left: 0px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
#controls {
|
||||
width: 100%;
|
||||
height: 55px;
|
||||
}
|
||||
|
||||
#jump {
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 1px solid red;
|
||||
z-index: 10000;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#cockpitInput {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
|
||||
border: none; outline: none;
|
||||
font-family: consolas, courier, monospace;
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
#cockpitOutput {
|
||||
padding: 10px;
|
||||
margin: 0 15px;
|
||||
border: 1px solid #AAA;
|
||||
-moz-border-radius-topleft: 10px;
|
||||
-moz-border-radius-topright: 10px;
|
||||
border-top-left-radius: 4px; border-top-right-radius: 4px;
|
||||
background: #DDD; color: #000;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="jump"></div>
|
||||
|
||||
<table id="controls">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="doc">Document:</label>
|
||||
<select id="doc" size="1">
|
||||
<option value="js">JS Document</option>
|
||||
<option value="html">HTML Document</option>
|
||||
<option value="css">CSS Document</option>
|
||||
<option value="python">Python Document</option>
|
||||
<option value="php">PHP Document</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label for="mode">Mode:</label>
|
||||
<select id="mode" size="1">
|
||||
<option value="text">Plain Text</option>
|
||||
<option value="javascript">JavaScript</option>
|
||||
<option value="xml">XML</option>
|
||||
<option value="html">HTML</option>
|
||||
<option value="css">CSS</option>
|
||||
<option value="python">Python</option>
|
||||
<option value="php">PHP</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label for="theme">Theme:</label>
|
||||
<select id="theme" size="1">
|
||||
<option value="ace/theme/textmate">TextMate</option>
|
||||
<option value="ace/theme/eclipse">Eclipse</option>
|
||||
<option value="ace/theme/dawn">Dawn</option>
|
||||
<option value="ace/theme/idle_fingers">idleFingers</option>
|
||||
<option value="ace/theme/pastel_on_dark">Pastel on dark</option>
|
||||
<option value="ace/theme/twilight">Twilight</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label for="select_style">Full line selections</label>
|
||||
<input type="checkbox" name="select_style" id="select_style" checked>
|
||||
</td>
|
||||
<td>
|
||||
<label for="highlight_active">Highlight active line</label>
|
||||
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
|
||||
</td>
|
||||
<td>
|
||||
<label for="show_hidden">Show invisibles</label>
|
||||
<input type="checkbox" name="show_hidden" id="show_hidden">
|
||||
</td>
|
||||
<td align="right">
|
||||
<img src="demo/logo.png">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="editor">
|
||||
</div>
|
||||
|
||||
<script type="text/editor" id="jstext">function foo(items) {
|
||||
for (var i=0; i<items.length; i++) {
|
||||
alert(items[i] + "juhu");
|
||||
}
|
||||
}</script>
|
||||
|
||||
<script type="text/editor" id="csstext">.text-layer {
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 12px;
|
||||
cursor: text;
|
||||
}</script>
|
||||
|
||||
<script type="text/editor" id="htmltext"><html>
|
||||
<head>
|
||||
|
||||
<style type="text/css">
|
||||
.text-layer {
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 12px;
|
||||
cursor: text;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="color:red">Juhu Kinners</h1>
|
||||
</body>
|
||||
</html></script>
|
||||
|
||||
<script type="text/editor" id="pythontext">#!/usr/local/bin/python
|
||||
|
||||
import string, sys
|
||||
|
||||
# If no arguments were given, print a helpful message
|
||||
if len(sys.argv)==1:
|
||||
print 'Usage: celsius temp1 temp2 ...'
|
||||
sys.exit(0)
|
||||
|
||||
# Loop over the arguments
|
||||
for i in sys.argv[1:]:
|
||||
try:
|
||||
fahrenheit=float(string.atoi(i))
|
||||
except string.atoi_error:
|
||||
print repr(i), "not a numeric value"
|
||||
else:
|
||||
celsius=(fahrenheit-32)*5.0/9.0
|
||||
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="phptext"><?php
|
||||
|
||||
function nfact($n) {
|
||||
if ($n == 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return $n * nfact($n - 1);
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n\nPlease enter a whole number ... ";
|
||||
$num = trim(fgets(STDIN));
|
||||
|
||||
// ===== PROCESS - Determing the factorial of the input number =====
|
||||
$output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
|
||||
echo $output;
|
||||
|
||||
?></script>
|
||||
|
||||
<input id="cockpitInput" type="text"/>
|
||||
|
||||
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="demo/boot.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script type="text/javascript">
|
||||
require("demo/boot");
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -113,6 +113,10 @@
|
|||
<label for="highlight_active">Highlight active line</label>
|
||||
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
|
||||
</td>
|
||||
<td>
|
||||
<label for="show_hidden">Show invisibles</label>
|
||||
<input type="checkbox" name="show_hidden" id="show_hidden">
|
||||
</td>
|
||||
<td align="right">
|
||||
<img src="demo/logo.png">
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
<br/>
|
||||
<br/> </p>
|
||||
<h2>Demo</h2>
|
||||
Check out the <a href="editor.html">demo</a>.
|
||||
Check out the <a href="editor-build.html">demo</a>.
|
||||
<h2>Contact</h2>
|
||||
<p>Fabian Jakobs (fabian.jakobs@web.de)
|
||||
<br/> </p>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -42,7 +42,7 @@ var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
|||
|
||||
var BackgroundTokenizer = function(tokenizer, editor) {
|
||||
this.running = false;
|
||||
this.textLines = [];
|
||||
this.doc = [];
|
||||
this.lines = [];
|
||||
this.currentLine = 0;
|
||||
this.tokenizer = tokenizer;
|
||||
|
|
@ -54,12 +54,13 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
|
||||
var workerStart = new Date();
|
||||
var startLine = self.currentLine;
|
||||
var textLines = self.textLines;
|
||||
var doc = self.doc;
|
||||
|
||||
var processedLines = 0;
|
||||
var lastVisibleRow = editor.getLastVisibleRow();
|
||||
|
||||
while (self.currentLine < textLines.length) {
|
||||
var len = doc.getLength();
|
||||
while (self.currentLine < len) {
|
||||
self.lines[self.currentLine] = self.$tokenizeRows(self.currentLine, self.currentLine)[0];
|
||||
self.currentLine++;
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
|
||||
self.running = false;
|
||||
|
||||
self.fireUpdateEvent(startLine, textLines.length - 1);
|
||||
self.fireUpdateEvent(startLine, len - 1);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -91,8 +92,8 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
this.start(0);
|
||||
};
|
||||
|
||||
this.setLines = function(textLines) {
|
||||
this.textLines = textLines;
|
||||
this.setDocument = function(doc) {
|
||||
this.doc = doc;
|
||||
this.lines = [];
|
||||
|
||||
this.stop();
|
||||
|
|
@ -108,7 +109,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
|
||||
this.start = function(startRow) {
|
||||
this.currentLine = Math.min(startRow || 0, this.currentLine,
|
||||
this.textLines.length);
|
||||
this.doc.getLength());
|
||||
|
||||
// remove all cached items below this line
|
||||
this.lines.splice(this.currentLine, this.lines.length);
|
||||
|
|
@ -124,12 +125,12 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
this.running = false;
|
||||
};
|
||||
|
||||
this.getTokens = function(firstRow, lastRow, callback) {
|
||||
callback(this.$tokenizeRows(firstRow, lastRow));
|
||||
this.getTokens = function(firstRow, lastRow) {
|
||||
return this.$tokenizeRows(firstRow, lastRow);
|
||||
};
|
||||
|
||||
this.getState = function(row, callback) {
|
||||
callback(this.$tokenizeRows(row, row)[0].state);
|
||||
this.getState = function(row) {
|
||||
return this.$tokenizeRows(row, row)[0].state;
|
||||
};
|
||||
|
||||
this.$tokenizeRows = function(firstRow, lastRow) {
|
||||
|
|
@ -143,9 +144,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
doCache = true;
|
||||
}
|
||||
|
||||
var lines = this.doc.getLines(firstRow, lastRow);
|
||||
for (var row=firstRow; row<=lastRow; row++) {
|
||||
if (!this.lines[row]) {
|
||||
var tokens = this.tokenizer.getLineTokens(this.textLines[row] || "", state);
|
||||
var tokens = this.tokenizer.getLineTokens(lines[row-firstRow] || "", state);
|
||||
var state = tokens.state;
|
||||
rows.push(tokens);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Julian Viereck <julian.viereck@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -37,8 +38,14 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var lang = require("pilot/lang");
|
||||
var canon = require("pilot/canon");
|
||||
|
||||
canon.addCommand({
|
||||
name: "null",
|
||||
exec: function(env, args, request) { }
|
||||
});
|
||||
|
||||
canon.addCommand({
|
||||
name: "selectall",
|
||||
exec: function(env, args, request) { env.editor.getSelection().selectAll(); }
|
||||
|
|
@ -113,7 +120,7 @@ canon.addCommand({
|
|||
});
|
||||
canon.addCommand({
|
||||
name: "golineup",
|
||||
exec: function(env, args, request) { env.editor.navigateUp(); }
|
||||
exec: function(env, args, request) { env.editor.navigateUp(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
name: "copylinesdown",
|
||||
|
|
@ -136,8 +143,8 @@ canon.addCommand({
|
|||
exec: function(env, args, request) { env.editor.getSelection().selectDown(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
name: "godown",
|
||||
exec: function(env, args, request) { env.editor.navigateDown(); }
|
||||
name: "golinedown",
|
||||
exec: function(env, args, request) { env.editor.navigateDown(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
name: "selectwordleft",
|
||||
|
|
@ -161,7 +168,7 @@ canon.addCommand({
|
|||
});
|
||||
canon.addCommand({
|
||||
name: "gotoleft",
|
||||
exec: function(env, args, request) { env.editor.navigateLeft(); }
|
||||
exec: function(env, args, request) { env.editor.navigateLeft(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
name: "selectwordright",
|
||||
|
|
@ -185,7 +192,7 @@ canon.addCommand({
|
|||
});
|
||||
canon.addCommand({
|
||||
name: "gotoright",
|
||||
exec: function(env, args, request) { env.editor.navigateRight(); }
|
||||
exec: function(env, args, request) { env.editor.navigateRight(args.times); }
|
||||
});
|
||||
canon.addCommand({
|
||||
name: "selectpagedown",
|
||||
|
|
@ -243,5 +250,12 @@ canon.addCommand({
|
|||
name: "indent",
|
||||
exec: function(env, args, request) { env.editor.indent(); }
|
||||
});
|
||||
canon.addCommand({
|
||||
name: "inserttext",
|
||||
exec: function(env, args, request) {
|
||||
env.editor.insert(lang.stringRepeat(args.text || "",
|
||||
args.times || 1));
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,17 +32,28 @@
|
|||
left: 0px;
|
||||
}
|
||||
|
||||
.ace_editor .ace_printMargin {
|
||||
.ace_editor .ace_print_margin_layer {
|
||||
z-index: 0;
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
margin: 0px;
|
||||
left: 0px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ace_editor .ace_print_margin {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.ace_layer {
|
||||
z-index: 0;
|
||||
z-index: 1;
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ace_text-layer {
|
||||
|
|
@ -55,7 +66,7 @@
|
|||
}
|
||||
|
||||
.ace_cursor {
|
||||
z-index: 3;
|
||||
z-index: 4;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
|
@ -68,20 +79,20 @@
|
|||
|
||||
.ace_marker-layer .ace_step {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.ace_marker-layer .ace_selection {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.ace_marker-layer .ace_bracket {
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.ace_marker-layer .ace_active_line {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
z-index: 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -38,160 +38,44 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("pilot/oop");
|
||||
var lang = require("pilot/lang");
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
var Selection = require("ace/selection").Selection;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var Document = function(text, mode) {
|
||||
|
||||
this.modified = true;
|
||||
this.lines = [];
|
||||
this.selection = new Selection(this);
|
||||
this.$breakpoints = [];
|
||||
var Document = function(text) {
|
||||
this.$lines = [];
|
||||
|
||||
this.listeners = [];
|
||||
if (mode) {
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
if (Array.isArray(text)) {
|
||||
this.$insertLines(0, text);
|
||||
this.insertLines(0, text);
|
||||
} else {
|
||||
this.$insert({row: 0, column: 0}, text);
|
||||
this.insert({row: 0, column:0}, text);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.$undoManager = null;
|
||||
|
||||
this.$split = function(text) {
|
||||
return text.split(/\r\n|\r|\n/);
|
||||
this.setValue = function(text) {
|
||||
var len = this.getLength();
|
||||
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
|
||||
this.insertLines(0, this.$split(text));
|
||||
};
|
||||
|
||||
this.setValue = function(text) {
|
||||
var args = [0, this.lines.length];
|
||||
args.push.apply(args, this.$split(text));
|
||||
this.lines.splice.apply(this.lines, args);
|
||||
this.modified = true;
|
||||
this.fireChangeEvent(0);
|
||||
};
|
||||
|
||||
this.toString = function() {
|
||||
return this.lines.join(this.$getNewLineCharacter());
|
||||
};
|
||||
|
||||
this.getSelection = function() {
|
||||
return this.selection;
|
||||
};
|
||||
|
||||
this.fireChangeEvent = function(firstRow, lastRow) {
|
||||
var data = {
|
||||
firstRow: firstRow,
|
||||
lastRow: lastRow
|
||||
};
|
||||
this._dispatchEvent("change", { data: data});
|
||||
};
|
||||
|
||||
this.setUndoManager = function(undoManager) {
|
||||
this.$undoManager = undoManager;
|
||||
this.$deltas = [];
|
||||
|
||||
if (this.$informUndoManager) {
|
||||
this.$informUndoManager.cancel();
|
||||
}
|
||||
|
||||
if (undoManager) {
|
||||
//undoManager.setDocument(this);
|
||||
var self = this;
|
||||
this.$informUndoManager = lang.deferredCall(function() {
|
||||
if (self.$deltas.length > 0)
|
||||
undoManager.execute({
|
||||
action : "aceupdate",
|
||||
args : [self.$deltas, self]
|
||||
});
|
||||
self.$deltas = [];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.$defaultUndoManager = {
|
||||
undo: function() {},
|
||||
redo: function() {}
|
||||
};
|
||||
|
||||
this.getUndoManager = function() {
|
||||
return this.$undoManager || this.$defaultUndoManager;
|
||||
},
|
||||
|
||||
this.getTabString = function() {
|
||||
if (this.getUseSoftTabs()) {
|
||||
return lang.stringRepeat(" ", this.getTabSize());
|
||||
} else {
|
||||
return "\t";
|
||||
}
|
||||
};
|
||||
|
||||
this.$useSoftTabs = true;
|
||||
this.setUseSoftTabs = function(useSoftTabs) {
|
||||
if (this.$useSoftTabs === useSoftTabs) return;
|
||||
|
||||
this.$useSoftTabs = useSoftTabs;
|
||||
};
|
||||
|
||||
this.getUseSoftTabs = function() {
|
||||
return this.$useSoftTabs;
|
||||
};
|
||||
|
||||
this.$tabSize = 4;
|
||||
this.setTabSize = function(tabSize) {
|
||||
if (isNaN(tabSize) || this.$tabSize === tabSize) return;
|
||||
|
||||
this.modified = true;
|
||||
this.$tabSize = tabSize;
|
||||
this._dispatchEvent("changeTabSize");
|
||||
};
|
||||
|
||||
this.getTabSize = function() {
|
||||
return this.$tabSize;
|
||||
|
||||
this.getValue = function() {
|
||||
return this.$lines.join(this.getNewLineCharacter());
|
||||
};
|
||||
|
||||
this.isTabStop = function(position) {
|
||||
return this.$useSoftTabs && (position.column % this.$tabSize == 0);
|
||||
};
|
||||
|
||||
this.getBreakpoints = function() {
|
||||
return this.$breakpoints;
|
||||
};
|
||||
|
||||
this.setBreakpoints = function(rows) {
|
||||
this.$breakpoints = [];
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
this.$breakpoints[rows[i]] = true;
|
||||
// check for IE split bug
|
||||
if ("aaa".split(/a/).length == 0)
|
||||
this.$split = function(text) {
|
||||
return text.replace(/\r\n|\r/g, "\n").split("\n");
|
||||
}
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoints = function() {
|
||||
this.$breakpoints = [];
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.setBreakpoint = function(row) {
|
||||
this.$breakpoints[row] = true;
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoint = function(row) {
|
||||
delete this.$breakpoints[row];
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
else
|
||||
this.$split = function(text) {
|
||||
return text.split(/\r\n|\r|\n/);
|
||||
};
|
||||
|
||||
|
||||
this.$detectNewLine = function(text) {
|
||||
var match = text.match(/^.*?(\r?\n)/m);
|
||||
if (match) {
|
||||
|
|
@ -201,41 +85,7 @@ var Document = function(text, mode) {
|
|||
}
|
||||
};
|
||||
|
||||
this.tokenRe = /^[\w\d]+/g;
|
||||
this.nonTokenRe = /^[^\w\d]+/g;
|
||||
|
||||
this.getWordRange = function(row, column) {
|
||||
var line = this.getLine(row);
|
||||
|
||||
var inToken = false;
|
||||
if (column > 0) {
|
||||
inToken = !!line.charAt(column - 1).match(this.tokenRe);
|
||||
}
|
||||
|
||||
if (!inToken) {
|
||||
inToken = !!line.charAt(column).match(this.tokenRe);
|
||||
}
|
||||
|
||||
var re = inToken ? this.tokenRe : this.nonTokenRe;
|
||||
|
||||
var start = column;
|
||||
if (start > 0) {
|
||||
do {
|
||||
start--;
|
||||
}
|
||||
while (start >= 0 && line.charAt(start).match(re));
|
||||
start++;
|
||||
}
|
||||
|
||||
var end = column;
|
||||
while (end < line.length && line.charAt(end).match(re)) {
|
||||
end++;
|
||||
}
|
||||
|
||||
return new Range(row, start, row, end);
|
||||
};
|
||||
|
||||
this.$getNewLineCharacter = function() {
|
||||
this.getNewLineCharacter = function() {
|
||||
switch (this.$newLineMode) {
|
||||
case "windows":
|
||||
return "\r\n";
|
||||
|
|
@ -259,496 +109,281 @@ var Document = function(text, mode) {
|
|||
this.getNewLineMode = function() {
|
||||
return this.$newLineMode;
|
||||
};
|
||||
|
||||
this.$mode = null;
|
||||
this.setMode = function(mode) {
|
||||
if (this.$mode === mode) return;
|
||||
|
||||
this.$mode = mode;
|
||||
this._dispatchEvent("changeMode");
|
||||
};
|
||||
|
||||
this.getMode = function() {
|
||||
if (!this.$mode) {
|
||||
this.$mode = new TextMode();
|
||||
}
|
||||
return this.$mode;
|
||||
};
|
||||
|
||||
this.$scrollTop = 0;
|
||||
this.setScrollTopRow = function(scrollTopRow) {
|
||||
if (this.$scrollTop === scrollTopRow) return;
|
||||
|
||||
this.$scrollTop = scrollTopRow;
|
||||
this._dispatchEvent("changeScrollTop");
|
||||
};
|
||||
|
||||
this.getScrollTopRow = function() {
|
||||
return this.$scrollTop;
|
||||
};
|
||||
|
||||
this.getWidth = function() {
|
||||
this.$computeWidth();
|
||||
return this.width;
|
||||
};
|
||||
|
||||
this.getScreenWidth = function() {
|
||||
this.$computeWidth();
|
||||
return this.screenWith;
|
||||
};
|
||||
|
||||
this.$computeWidth = function() {
|
||||
if (this.modified) {
|
||||
this.modified = false;
|
||||
|
||||
var lines = this.lines;
|
||||
var longestLine = 0;
|
||||
var longestScreenLine = 0;
|
||||
var tabSize = this.getTabSize();
|
||||
|
||||
for ( var i = 0; i < lines.length; i++) {
|
||||
var len = lines[i].length;
|
||||
longestLine = Math.max(longestLine, len);
|
||||
|
||||
lines[i].replace("\t", function(m) {
|
||||
len += tabSize-1;
|
||||
return m;
|
||||
});
|
||||
longestScreenLine = Math.max(longestScreenLine, len);
|
||||
}
|
||||
this.width = longestLine;
|
||||
this.screenWith = longestScreenLine;
|
||||
}
|
||||
|
||||
this.isNewLine = function(text) {
|
||||
return (text == "\r\n" || text == "\r" || text == "\n");
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a verbatim copy of the given line as it is in the document
|
||||
*/
|
||||
this.getLine = function(row) {
|
||||
return this.lines[row] || "";
|
||||
return this.$lines[row] || "";
|
||||
};
|
||||
|
||||
this.getLines = function(firstRow, lastRow) {
|
||||
return this.$lines.slice(firstRow, lastRow+1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a line as it is displayed on screen. Tabs are replaced by spaces.
|
||||
* Returns all lines in the document as string array. Warning: The caller
|
||||
* should not modify this array!
|
||||
*/
|
||||
this.getDisplayLine = function(row) {
|
||||
var tab = new Array(this.getTabSize()+1).join(" ");
|
||||
return this.lines[row].replace(/\t/g, tab);
|
||||
};
|
||||
|
||||
this.getLines = function(firstRow, lastRow) {
|
||||
return this.lines.slice(firstRow, lastRow+1);
|
||||
this.getAllLines = function() {
|
||||
return this.$lines;
|
||||
};
|
||||
|
||||
this.getLength = function() {
|
||||
return this.lines.length;
|
||||
return this.$lines.length;
|
||||
};
|
||||
|
||||
this.getTextRange = function(range) {
|
||||
if (range.start.row == range.end.row) {
|
||||
return this.lines[range.start.row].substring(range.start.column,
|
||||
return this.$lines[range.start.row].substring(range.start.column,
|
||||
range.end.column);
|
||||
}
|
||||
else {
|
||||
var lines = [];
|
||||
lines.push(this.lines[range.start.row].substring(range.start.column));
|
||||
lines.push(this.$lines[range.start.row].substring(range.start.column));
|
||||
lines.push.apply(lines, this.getLines(range.start.row+1, range.end.row-1));
|
||||
lines.push(this.lines[range.end.row].substring(0, range.end.column));
|
||||
return lines.join(this.$getNewLineCharacter());
|
||||
lines.push(this.$lines[range.end.row].substring(0, range.end.column));
|
||||
return lines.join(this.getNewLineCharacter());
|
||||
}
|
||||
};
|
||||
|
||||
this.findMatchingBracket = function(position) {
|
||||
if (position.column == 0) return null;
|
||||
|
||||
var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
|
||||
if (charBeforeCursor == "") return null;
|
||||
|
||||
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
|
||||
if (!match) {
|
||||
return null;
|
||||
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;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
if (match[1]) {
|
||||
return this.$findClosingBracket(match[1], position);
|
||||
} else {
|
||||
return this.$findOpeningBracket(match[2], position);
|
||||
}
|
||||
};
|
||||
|
||||
this.$brackets = {
|
||||
")": "(",
|
||||
"(": ")",
|
||||
"]": "[",
|
||||
"[": "]",
|
||||
"{": "}",
|
||||
"}": "{"
|
||||
};
|
||||
|
||||
this.$findOpeningBracket = function(bracket, position) {
|
||||
var openBracket = this.$brackets[bracket];
|
||||
|
||||
var column = position.column - 2;
|
||||
var row = position.row;
|
||||
var depth = 1;
|
||||
|
||||
var line = this.getLine(row);
|
||||
|
||||
while (true) {
|
||||
while(column >= 0) {
|
||||
var ch = line.charAt(column);
|
||||
if (ch == openBracket) {
|
||||
depth -= 1;
|
||||
if (depth == 0) {
|
||||
return {row: row, column: column};
|
||||
}
|
||||
}
|
||||
else if (ch == bracket) {
|
||||
depth +=1;
|
||||
}
|
||||
column -= 1;
|
||||
}
|
||||
row -=1;
|
||||
if (row < 0) break;
|
||||
|
||||
var line = this.getLine(row);
|
||||
var column = line.length-1;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.$findClosingBracket = function(bracket, position) {
|
||||
var closingBracket = this.$brackets[bracket];
|
||||
|
||||
var column = position.column;
|
||||
var row = position.row;
|
||||
var depth = 1;
|
||||
|
||||
var line = this.getLine(row);
|
||||
var lineCount = this.getLength();
|
||||
|
||||
while (true) {
|
||||
while(column < line.length) {
|
||||
var ch = line.charAt(column);
|
||||
if (ch == closingBracket) {
|
||||
depth -= 1;
|
||||
if (depth == 0) {
|
||||
return {row: row, column: column};
|
||||
}
|
||||
}
|
||||
else if (ch == bracket) {
|
||||
depth +=1;
|
||||
}
|
||||
column += 1;
|
||||
}
|
||||
row +=1;
|
||||
if (row >= lineCount) break;
|
||||
|
||||
var line = this.getLine(row);
|
||||
var column = 0;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.insert = function(position, text, fromUndo) {
|
||||
var end = this.$insert(position, text, fromUndo);
|
||||
this.fireChangeEvent(position.row, position.row == end.row ? position.row
|
||||
: undefined);
|
||||
return end;
|
||||
};
|
||||
|
||||
this.$insertLines = function(row, lines, fromUndo) {
|
||||
if (lines.length == 0)
|
||||
return;
|
||||
|
||||
var args = [row, 0];
|
||||
args.push.apply(args, lines);
|
||||
this.lines.splice.apply(this.lines, args);
|
||||
|
||||
if (!fromUndo && this.$undoManager) {
|
||||
var nl = this.$getNewLineCharacter();
|
||||
this.$deltas.push({
|
||||
action: "insertText",
|
||||
range: new Range(row, 0, row + lines.length, 0),
|
||||
text: lines.join(nl) + nl
|
||||
});
|
||||
this.$informUndoManager.schedule();
|
||||
}
|
||||
},
|
||||
|
||||
this.$insert = function(position, text, fromUndo) {
|
||||
this.insert = function(position, text) {
|
||||
if (text.length == 0)
|
||||
return position;
|
||||
|
||||
this.modified = true;
|
||||
if (this.lines.length <= 1) {
|
||||
|
||||
position = this.$clipPosition(position);
|
||||
|
||||
if (this.getLength() <= 1)
|
||||
this.$detectNewLine(text);
|
||||
}
|
||||
|
||||
var newLines = this.$split(text);
|
||||
|
||||
if (this.$isNewLine(text)) {
|
||||
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));
|
||||
|
||||
var end = {
|
||||
row : position.row + 1,
|
||||
column : 0
|
||||
};
|
||||
if (this.isNewLine(text)) {
|
||||
var end = this.insertNewLine(position);
|
||||
}
|
||||
else if (newLines.length == 1) {
|
||||
var line = this.lines[position.row] || "";
|
||||
this.lines[position.row] = line.substring(0, position.column) + text
|
||||
+ line.substring(position.column);
|
||||
|
||||
var end = {
|
||||
row : position.row,
|
||||
column : position.column + text.length
|
||||
};
|
||||
var end = this.insertInLine(position, text);
|
||||
}
|
||||
else {
|
||||
var line = this.lines[position.row] || "";
|
||||
var firstLine = line.substring(0, position.column) + newLines[0];
|
||||
var lastLine = newLines[newLines.length - 1] + line.substring(position.column);
|
||||
|
||||
this.lines[position.row] = firstLine;
|
||||
this.$insertLines(position.row + 1, [lastLine], true);
|
||||
|
||||
if (newLines.length > 2) {
|
||||
this.$insertLines(position.row + 1, newLines.slice(1, -1), true);
|
||||
}
|
||||
|
||||
var end = {
|
||||
row : position.row + newLines.length - 1,
|
||||
column : newLines[newLines.length - 1].length
|
||||
};
|
||||
}
|
||||
|
||||
if (!fromUndo && this.$undoManager) {
|
||||
this.$deltas.push({
|
||||
action: "insertText",
|
||||
range: Range.fromPoints(position, end),
|
||||
text: text
|
||||
});
|
||||
this.$informUndoManager.schedule();
|
||||
var end = this.insertInLine(position, newLines[0]);
|
||||
this.insertNewLine(end);
|
||||
if (newLines.length > 2)
|
||||
this.insertLines(position.row+1, newLines.slice(1, newLines.length-1));
|
||||
|
||||
var end = this.insertInLine({row: position.row + newLines.length - 1, column: 0}, newLines[newLines.length-1]);
|
||||
}
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
this.insertLines = function(row, lines) {
|
||||
if (lines.length == 0)
|
||||
return {row: row, column: 0};
|
||||
|
||||
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 - 1, 0);
|
||||
var delta = {
|
||||
action: "insertLines",
|
||||
range: range,
|
||||
lines: lines
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
return range.end;
|
||||
},
|
||||
|
||||
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._dispatchEvent("change", { data: delta });
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
this.insertInLine = function(position, text) {
|
||||
if (text.length == 0)
|
||||
return position;
|
||||
|
||||
var line = this.$lines[position.row] || "";
|
||||
this.$lines[position.row] = line.substring(0, position.column) + text
|
||||
+ line.substring(position.column);
|
||||
|
||||
this.$isNewLine = function(text) {
|
||||
return (text == "\r\n" || text == "\r" || text == "\n");
|
||||
var end = {
|
||||
row : position.row,
|
||||
column : position.column + text.length
|
||||
};
|
||||
|
||||
var delta = {
|
||||
action: "insertText",
|
||||
range: Range.fromPoints(position, end),
|
||||
text: text
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
this.remove = function(range, fromUndo) {
|
||||
this.remove = function(range) {
|
||||
// clip to document
|
||||
range.start = this.$clipPosition(range.start);
|
||||
range.end = this.$clipPosition(range.end);
|
||||
|
||||
if (range.isEmpty())
|
||||
return range.start;
|
||||
|
||||
this.$remove(range, fromUndo);
|
||||
|
||||
this.fireChangeEvent(range.start.row, range.isMultiLine() ? undefined : range.start.row);
|
||||
|
||||
return range.start;
|
||||
};
|
||||
|
||||
this.$remove = function(range, fromUndo) {
|
||||
if (range.isEmpty())
|
||||
return;
|
||||
|
||||
if (!fromUndo && this.$undoManager) {
|
||||
var nl = this.$getNewLineCharacter();
|
||||
this.$deltas.push({
|
||||
action: "removeText",
|
||||
range: range.clone(),
|
||||
text: this.getTextRange(range)
|
||||
});
|
||||
this.$informUndoManager.schedule();
|
||||
}
|
||||
|
||||
this.modified = true;
|
||||
|
||||
|
||||
var firstRow = range.start.row;
|
||||
var lastRow = range.end.row;
|
||||
|
||||
var row = this.getLine(firstRow).substring(0, range.start.column)
|
||||
+ this.getLine(lastRow).substring(range.end.column);
|
||||
|
||||
if (row != "")
|
||||
this.lines.splice(firstRow, lastRow - firstRow + 1, row);
|
||||
else
|
||||
this.lines.splice(firstRow, lastRow - firstRow + 1, "");
|
||||
if (range.isMultiLine()) {
|
||||
|
||||
// TODO removeInLine can be optimized away!
|
||||
this.removeInLine(lastRow, 0, range.end.column);
|
||||
if (lastRow - firstRow >= 2)
|
||||
this.removeLines(firstRow + 1, lastRow - 1);
|
||||
this.removeInLine(firstRow, range.start.column, this.$lines[firstRow].length);
|
||||
this.removeNewLine(range.start.row);
|
||||
}
|
||||
else {
|
||||
this.removeInLine(firstRow, range.start.column, range.end.column);
|
||||
}
|
||||
return range.start;
|
||||
};
|
||||
|
||||
this.undoChanges = function(deltas) {
|
||||
this.selection.clearSelection();
|
||||
for (var i=deltas.length-1; i>=0; i--) {
|
||||
var delta = deltas[i];
|
||||
if (delta.action == "insertText") {
|
||||
this.remove(delta.range, true);
|
||||
this.selection.moveCursorToPosition(delta.range.start);
|
||||
} else {
|
||||
this.insert(delta.range.start, delta.text, true);
|
||||
this.selection.clearSelection();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.redoChanges = function(deltas) {
|
||||
this.selection.clearSelection();
|
||||
for (var i=0; i<deltas.length; i++) {
|
||||
var delta = deltas[i];
|
||||
if (delta.action == "insertText") {
|
||||
this.insert(delta.range.start, delta.text, true);
|
||||
this.selection.setSelectionRange(delta.range);
|
||||
} else {
|
||||
this.remove(delta.range, true);
|
||||
this.selection.moveCursorToPosition(delta.range.start);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.removeInLine = function(row, startColumn, endColumn) {
|
||||
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._dispatchEvent("change", { data: delta });
|
||||
return range.start;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a range of full lines
|
||||
*
|
||||
* @param firstRow {Integer} The first row to be removed
|
||||
* @param lastRow {Integer} The last row to be removed
|
||||
* @return {String[]} The removed lines
|
||||
*/
|
||||
this.removeLines = function(firstRow, lastRow) {
|
||||
var range = new Range(firstRow, 0, lastRow, this.$lines[lastRow].length);
|
||||
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
|
||||
|
||||
var delta = {
|
||||
action: "removeLines",
|
||||
range: range,
|
||||
nl: this.getNewLineCharacter(),
|
||||
lines: removed
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
return removed;
|
||||
};
|
||||
|
||||
this.removeNewLine = function(row) {
|
||||
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._dispatchEvent("change", { data: delta });
|
||||
};
|
||||
|
||||
this.replace = function(range, text) {
|
||||
this.$remove(range);
|
||||
if (text.length == 0 && range.isEmpty())
|
||||
return range.start;
|
||||
|
||||
// Shortcut: If the text we want to insert is the same as it is already
|
||||
// in the document, we don't have to replace anything.
|
||||
if (text == this.getTextRange(range))
|
||||
return range.end;
|
||||
|
||||
this.remove(range);
|
||||
if (text) {
|
||||
var end = this.$insert(range.start, text);
|
||||
var end = this.insert(range.start, text);
|
||||
}
|
||||
else {
|
||||
end = range.start;
|
||||
}
|
||||
|
||||
var lastRemoved = range.end.column == 0 ? range.end.column - 1
|
||||
: range.end.column;
|
||||
this.fireChangeEvent(range.start.row, lastRemoved == end.row ? lastRemoved
|
||||
: undefined);
|
||||
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
this.indentRows = function(startRow, endRow, indentString) {
|
||||
indentString = indentString.replace("\t", this.getTabString());
|
||||
for (var row=startRow; row<=endRow; row++) {
|
||||
this.$insert({row: row, column:0}, indentString);
|
||||
}
|
||||
this.fireChangeEvent(startRow, endRow);
|
||||
return indentString.length;
|
||||
};
|
||||
|
||||
this.outdentRows = function (range) {
|
||||
var rowRange = range.collapseRows();
|
||||
var deleteRange = new Range(0, 0, 0, 0);
|
||||
var size = this.getTabSize();
|
||||
|
||||
for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
|
||||
var line = this.getLine(i);
|
||||
|
||||
this.applyDeltas = function(deltas) {
|
||||
for (var i=0; i<deltas.length; i++) {
|
||||
var delta = deltas[i];
|
||||
var range = Range.fromPoints(delta.range.start, delta.range.end);
|
||||
|
||||
deleteRange.start.row = i;
|
||||
deleteRange.end.row = i;
|
||||
for (var j = 0; j < size; ++j)
|
||||
if (line.charAt(j) != ' ')
|
||||
break;
|
||||
if (j < size && line.charAt(j) == '\t') {
|
||||
deleteRange.start.column = j;
|
||||
deleteRange.end.column = j + 1;
|
||||
} else {
|
||||
deleteRange.start.column = 0;
|
||||
deleteRange.end.column = j;
|
||||
}
|
||||
if (i == range.start.row)
|
||||
range.start.column -= deleteRange.end.column - deleteRange.start.column;
|
||||
if (i == range.end.row)
|
||||
range.end.column -= deleteRange.end.column - deleteRange.start.column;
|
||||
this.$remove(deleteRange);
|
||||
}
|
||||
this.fireChangeEvent(range.start.row, range.end.row);
|
||||
return range;
|
||||
}
|
||||
|
||||
this.moveLinesUp = function(firstRow, lastRow) {
|
||||
if (firstRow <= 0) return 0;
|
||||
|
||||
var removed = this.lines.slice(firstRow, lastRow + 1);
|
||||
this.$remove(new Range(firstRow-1, this.lines[firstRow-1].length, lastRow, this.lines[lastRow].length));
|
||||
this.$insertLines(firstRow - 1, removed);
|
||||
|
||||
this.fireChangeEvent(firstRow - 1, lastRow);
|
||||
return -1;
|
||||
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)
|
||||
else if (delta.action == "removeText")
|
||||
this.remove(range)
|
||||
}
|
||||
};
|
||||
|
||||
this.moveLinesDown = function(firstRow, lastRow) {
|
||||
if (lastRow >= this.lines.length-1) return 0;
|
||||
|
||||
var removed = this.lines.slice(firstRow, lastRow + 1);
|
||||
this.$remove(new Range(firstRow, 0, lastRow + 1, 0));
|
||||
this.$insertLines(firstRow+1, removed);
|
||||
|
||||
this.fireChangeEvent(firstRow, lastRow + 1);
|
||||
return 1;
|
||||
};
|
||||
|
||||
this.duplicateLines = function(firstRow, lastRow) {
|
||||
var firstRow = this.$clipRowToDocument(firstRow);
|
||||
var lastRow = this.$clipRowToDocument(lastRow);
|
||||
|
||||
var lines = this.getLines(firstRow, lastRow);
|
||||
this.$insertLines(firstRow, lines);
|
||||
|
||||
var addedRows = lastRow - firstRow + 1;
|
||||
this.fireChangeEvent(firstRow);
|
||||
|
||||
return addedRows;
|
||||
};
|
||||
|
||||
this.$clipRowToDocument = function(row) {
|
||||
return Math.max(0, Math.min(row, this.lines.length-1));
|
||||
};
|
||||
|
||||
this.documentToScreenColumn = function(row, docColumn) {
|
||||
var tabSize = this.getTabSize();
|
||||
|
||||
var screenColumn = 0;
|
||||
var remaining = docColumn;
|
||||
|
||||
var line = this.getLine(row).split("\t");
|
||||
for (var i=0; i<line.length; i++) {
|
||||
var len = line[i].length;
|
||||
if (remaining > len) {
|
||||
remaining -= (len + 1);
|
||||
screenColumn += len + tabSize;
|
||||
}
|
||||
else {
|
||||
screenColumn += remaining;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return screenColumn;
|
||||
};
|
||||
|
||||
this.screenToDocumentColumn = function(row, screenColumn) {
|
||||
var tabSize = this.getTabSize();
|
||||
|
||||
var docColumn = 0;
|
||||
var remaining = screenColumn;
|
||||
|
||||
var line = this.getLine(row).split("\t");
|
||||
for (var i=0; i<line.length; i++) {
|
||||
var len = line[i].length;
|
||||
if (remaining >= len + tabSize) {
|
||||
remaining -= (len + tabSize);
|
||||
docColumn += (len + 1);
|
||||
}
|
||||
else if (remaining > len){
|
||||
docColumn += len;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
docColumn += remaining;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return docColumn;
|
||||
|
||||
this.revertDeltas = function(deltas) {
|
||||
for (var i=deltas.length-1; i>=0; 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)
|
||||
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)
|
||||
}
|
||||
};
|
||||
|
||||
}).call(Document.prototype);
|
||||
|
|
|
|||
642
lib/ace/edit_session.js
Normal file
642
lib/ace/edit_session.js
Normal file
|
|
@ -0,0 +1,642 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("pilot/oop");
|
||||
var lang = require("pilot/lang");
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
var Selection = require("ace/selection").Selection;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var Range = require("ace/range").Range;
|
||||
var Document = require("ace/document").Document;
|
||||
|
||||
var NO_CHANGE_DELTAS = {};
|
||||
|
||||
var EditSession = function(text, mode) {
|
||||
this.$modified = true;
|
||||
this.selection = new Selection(this);
|
||||
this.$breakpoints = [];
|
||||
|
||||
this.listeners = [];
|
||||
if (mode) {
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
if (text instanceof Document) {
|
||||
this.setDocument(text)
|
||||
} else {
|
||||
this.setDocument(new Document(text));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
if (this.doc)
|
||||
throw new Error("Document is already set");
|
||||
|
||||
this.doc = doc;
|
||||
doc.on("change", this.onChange.bind(this));
|
||||
};
|
||||
|
||||
this.getDocument = function() {
|
||||
return this.doc;
|
||||
};
|
||||
|
||||
this.onChange = function(e) {
|
||||
var delta = e.data;
|
||||
this.$modified = true;
|
||||
if (!this.$fromUndo && this.$undoManager) {
|
||||
this.$deltas.push(delta);
|
||||
this.$informUndoManager.schedule();
|
||||
}
|
||||
this._dispatchEvent("change", e);
|
||||
};
|
||||
|
||||
this.setValue = function(text) {
|
||||
this.doc.setValue(text);
|
||||
this.$deltas = [];
|
||||
};
|
||||
|
||||
this.getValue =
|
||||
this.toString = function() {
|
||||
return this.doc.getValue();
|
||||
};
|
||||
|
||||
this.getSelection = function() {
|
||||
return this.selection;
|
||||
};
|
||||
|
||||
this.setUndoManager = function(undoManager) {
|
||||
this.$undoManager = undoManager;
|
||||
this.$deltas = [];
|
||||
|
||||
if (this.$informUndoManager) {
|
||||
this.$informUndoManager.cancel();
|
||||
}
|
||||
|
||||
if (undoManager) {
|
||||
var self = this;
|
||||
this.$informUndoManager = lang.deferredCall(function() {
|
||||
if (self.$deltas.length > 0)
|
||||
undoManager.execute({
|
||||
action : "aceupdate",
|
||||
args : [self.$deltas, self]
|
||||
});
|
||||
self.$deltas = [];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.$defaultUndoManager = {
|
||||
undo: function() {},
|
||||
redo: function() {}
|
||||
};
|
||||
|
||||
this.getUndoManager = function() {
|
||||
return this.$undoManager || this.$defaultUndoManager;
|
||||
},
|
||||
|
||||
this.getTabString = function() {
|
||||
if (this.getUseSoftTabs()) {
|
||||
return lang.stringRepeat(" ", this.getTabSize());
|
||||
} else {
|
||||
return "\t";
|
||||
}
|
||||
};
|
||||
|
||||
this.$useSoftTabs = true;
|
||||
this.setUseSoftTabs = function(useSoftTabs) {
|
||||
if (this.$useSoftTabs === useSoftTabs) return;
|
||||
|
||||
this.$useSoftTabs = useSoftTabs;
|
||||
};
|
||||
|
||||
this.getUseSoftTabs = function() {
|
||||
return this.$useSoftTabs;
|
||||
};
|
||||
|
||||
this.$tabSize = 4;
|
||||
this.setTabSize = function(tabSize) {
|
||||
if (isNaN(tabSize) || this.$tabSize === tabSize) return;
|
||||
|
||||
this.$modified = true;
|
||||
this.$tabSize = tabSize;
|
||||
this._dispatchEvent("changeTabSize");
|
||||
};
|
||||
|
||||
this.getTabSize = function() {
|
||||
return this.$tabSize;
|
||||
};
|
||||
|
||||
this.isTabStop = function(position) {
|
||||
return this.$useSoftTabs && (position.column % this.$tabSize == 0);
|
||||
};
|
||||
|
||||
this.getBreakpoints = function() {
|
||||
return this.$breakpoints;
|
||||
};
|
||||
|
||||
this.setBreakpoints = function(rows) {
|
||||
this.$breakpoints = [];
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
this.$breakpoints[rows[i]] = true;
|
||||
}
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoints = function() {
|
||||
this.$breakpoints = [];
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.setBreakpoint = function(row) {
|
||||
this.$breakpoints[row] = true;
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoint = function(row) {
|
||||
delete this.$breakpoints[row];
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.$detectNewLine = function(text) {
|
||||
var match = text.match(/^.*?(\r?\n)/m);
|
||||
if (match) {
|
||||
this.$autoNewLine = match[1];
|
||||
} else {
|
||||
this.$autoNewLine = "\n";
|
||||
}
|
||||
};
|
||||
|
||||
this.tokenRe = /^[\w\d]+/g;
|
||||
this.nonTokenRe = /^[^\w\d]+/g;
|
||||
|
||||
this.getWordRange = function(row, column) {
|
||||
var line = this.getLine(row);
|
||||
|
||||
var inToken = false;
|
||||
if (column > 0) {
|
||||
inToken = !!line.charAt(column - 1).match(this.tokenRe);
|
||||
}
|
||||
|
||||
if (!inToken) {
|
||||
inToken = !!line.charAt(column).match(this.tokenRe);
|
||||
}
|
||||
|
||||
var re = inToken ? this.tokenRe : this.nonTokenRe;
|
||||
|
||||
var start = column;
|
||||
if (start > 0) {
|
||||
do {
|
||||
start--;
|
||||
}
|
||||
while (start >= 0 && line.charAt(start).match(re));
|
||||
start++;
|
||||
}
|
||||
|
||||
var end = column;
|
||||
while (end < line.length && line.charAt(end).match(re)) {
|
||||
end++;
|
||||
}
|
||||
|
||||
return new Range(row, start, row, end);
|
||||
};
|
||||
|
||||
this.setNewLineMode = function(newLineMode) {
|
||||
this.doc.setNewLineMode(newLineMode);
|
||||
};
|
||||
|
||||
this.getNewLineMode = function() {
|
||||
return this.doc.getNewLineMode();
|
||||
};
|
||||
|
||||
this.$mode = null;
|
||||
this.setMode = function(mode) {
|
||||
if (this.$mode === mode) return;
|
||||
|
||||
this.$mode = mode;
|
||||
this._dispatchEvent("changeMode");
|
||||
};
|
||||
|
||||
this.getMode = function() {
|
||||
if (!this.$mode) {
|
||||
this.$mode = new TextMode();
|
||||
}
|
||||
return this.$mode;
|
||||
};
|
||||
|
||||
this.$scrollTop = 0;
|
||||
this.setScrollTopRow = function(scrollTopRow) {
|
||||
if (this.$scrollTop === scrollTopRow) return;
|
||||
|
||||
this.$scrollTop = scrollTopRow;
|
||||
this._dispatchEvent("changeScrollTop");
|
||||
};
|
||||
|
||||
this.getScrollTopRow = function() {
|
||||
return this.$scrollTop;
|
||||
};
|
||||
|
||||
this.getWidth = function() {
|
||||
this.$computeWidth();
|
||||
return this.width;
|
||||
};
|
||||
|
||||
this.getScreenWidth = function() {
|
||||
this.$computeWidth();
|
||||
return this.screenWidth;
|
||||
};
|
||||
|
||||
this.$computeWidth = function() {
|
||||
if (this.$modified) {
|
||||
this.$modified = false;
|
||||
|
||||
var lines = this.doc.getAllLines();
|
||||
var longestLine = 0;
|
||||
var longestScreenLine = 0;
|
||||
var tabSize = this.getTabSize();
|
||||
|
||||
for ( var i = 0; i < lines.length; i++) {
|
||||
var len = lines[i].length;
|
||||
longestLine = Math.max(longestLine, len);
|
||||
|
||||
lines[i].replace(/\t/g, function(m) {
|
||||
len += tabSize-1;
|
||||
return m;
|
||||
});
|
||||
longestScreenLine = Math.max(longestScreenLine, len);
|
||||
}
|
||||
this.width = longestLine;
|
||||
this.screenWidth = longestScreenLine;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a verbatim copy of the given line as it is in the document
|
||||
*/
|
||||
this.getLine = function(row) {
|
||||
return this.doc.getLine(row);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a line as it is displayed on screen. Tabs are replaced by spaces.
|
||||
*/
|
||||
this.getDisplayLine = function(row) {
|
||||
var tab = new Array(this.getTabSize()+1).join(" ");
|
||||
return this.doc.getLine(row).replace(/\t/g, tab);
|
||||
};
|
||||
|
||||
this.getLines = function(firstRow, lastRow) {
|
||||
return this.doc.getLines(firstRow, lastRow);
|
||||
};
|
||||
|
||||
this.getLength = function() {
|
||||
return this.doc.getLength();
|
||||
};
|
||||
|
||||
this.getTextRange = function(range) {
|
||||
return this.doc.getTextRange(range);
|
||||
};
|
||||
|
||||
this.findMatchingBracket = function(position) {
|
||||
if (position.column == 0) return null;
|
||||
|
||||
var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
|
||||
if (charBeforeCursor == "") return null;
|
||||
|
||||
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (match[1]) {
|
||||
return this.$findClosingBracket(match[1], position);
|
||||
} else {
|
||||
return this.$findOpeningBracket(match[2], position);
|
||||
}
|
||||
};
|
||||
|
||||
this.$brackets = {
|
||||
")": "(",
|
||||
"(": ")",
|
||||
"]": "[",
|
||||
"[": "]",
|
||||
"{": "}",
|
||||
"}": "{"
|
||||
};
|
||||
|
||||
this.$findOpeningBracket = function(bracket, position) {
|
||||
var openBracket = this.$brackets[bracket];
|
||||
|
||||
var column = position.column - 2;
|
||||
var row = position.row;
|
||||
var depth = 1;
|
||||
|
||||
var line = this.getLine(row);
|
||||
|
||||
while (true) {
|
||||
while(column >= 0) {
|
||||
var ch = line.charAt(column);
|
||||
if (ch == openBracket) {
|
||||
depth -= 1;
|
||||
if (depth == 0) {
|
||||
return {row: row, column: column};
|
||||
}
|
||||
}
|
||||
else if (ch == bracket) {
|
||||
depth +=1;
|
||||
}
|
||||
column -= 1;
|
||||
}
|
||||
row -=1;
|
||||
if (row < 0) break;
|
||||
|
||||
var line = this.getLine(row);
|
||||
var column = line.length-1;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.$findClosingBracket = function(bracket, position) {
|
||||
var closingBracket = this.$brackets[bracket];
|
||||
|
||||
var column = position.column;
|
||||
var row = position.row;
|
||||
var depth = 1;
|
||||
|
||||
var line = this.getLine(row);
|
||||
var lineCount = this.getLength();
|
||||
|
||||
while (true) {
|
||||
while(column < line.length) {
|
||||
var ch = line.charAt(column);
|
||||
if (ch == closingBracket) {
|
||||
depth -= 1;
|
||||
if (depth == 0) {
|
||||
return {row: row, column: column};
|
||||
}
|
||||
}
|
||||
else if (ch == bracket) {
|
||||
depth +=1;
|
||||
}
|
||||
column += 1;
|
||||
}
|
||||
row +=1;
|
||||
if (row >= lineCount) break;
|
||||
|
||||
var line = this.getLine(row);
|
||||
var column = 0;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.insert = function(position, text) {
|
||||
return this.doc.insert(position, text);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rows Array[Integer] sorted list of rows
|
||||
*/
|
||||
this.multiRowInsert = function(rows, column, text) {
|
||||
for (var i=rows.length-1; i>=0; i--) {
|
||||
var row = rows[i];
|
||||
if (row >= this.doc.getLength())
|
||||
continue;
|
||||
|
||||
var diff = column - this.doc.getLine(row).length;
|
||||
if ( diff > 0) {
|
||||
var padded = lang.stringRepeat(" ", diff) + text;
|
||||
var offset = -diff;
|
||||
}
|
||||
else {
|
||||
padded = text;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
var end = this.insert({row: row, column: column+offset}, padded);
|
||||
}
|
||||
|
||||
return {
|
||||
rows: end ? end.row - rows[0] : 0,
|
||||
columns: end ? end.column - column : 0
|
||||
}
|
||||
};
|
||||
|
||||
this.remove = function(range) {
|
||||
return this.doc.remove(range);
|
||||
};
|
||||
|
||||
this.multiRowRemove = function(rows, range) {
|
||||
if (range.start.row !== rows[0])
|
||||
throw new TypeError("range must start in the first row!");
|
||||
|
||||
var height = range.end.row - rows[0];
|
||||
for (var i=rows.length-1; i>=0; i--) {
|
||||
var row = rows[i];
|
||||
if (row >= this.doc.getLength())
|
||||
continue;
|
||||
|
||||
var end = this.remove(new Range(row, range.start.column, row+height, range.end.column));
|
||||
}
|
||||
};
|
||||
|
||||
this.undoChanges = function(deltas) {
|
||||
if (!deltas.length)
|
||||
return;
|
||||
|
||||
this.$fromUndo = true;
|
||||
this.doc.revertDeltas(deltas);
|
||||
this.$fromUndo = false;
|
||||
|
||||
// update the selection
|
||||
var firstDelta = deltas[0];
|
||||
var lastDelta = deltas[deltas.length-1];
|
||||
|
||||
this.selection.clearSelection();
|
||||
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
|
||||
this.selection.moveCursorToPosition(firstDelta.range.start);
|
||||
if (firstDelta.action == "removeText" || firstDelta.action == "removeLines")
|
||||
this.selection.setSelectionRange(Range.fromPoints(firstDelta.range.start, lastDelta.range.end));
|
||||
},
|
||||
|
||||
this.redoChanges = function(deltas) {
|
||||
if (!deltas.length)
|
||||
return;
|
||||
|
||||
this.$fromUndo = true;
|
||||
this.doc.applyDeltas(deltas);
|
||||
this.$fromUndo = false;
|
||||
|
||||
// update the selection
|
||||
var firstDelta = deltas[0];
|
||||
var lastDelta = deltas[deltas.length-1];
|
||||
|
||||
this.selection.clearSelection();
|
||||
if (firstDelta.action == "insertText" || firstDelta.action == "insertLines")
|
||||
this.selection.setSelectionRange(Range.fromPoints(firstDelta.range.start, lastDelta.range.end));
|
||||
if (firstDelta.action == "removeText" || firstDelta.action == "removeLines")
|
||||
this.selection.moveCursorToPosition(firstDelta.range.start);
|
||||
},
|
||||
|
||||
this.replace = function(range, text) {
|
||||
return this.doc.replace(range, text);
|
||||
};
|
||||
|
||||
this.indentRows = function(startRow, endRow, indentString) {
|
||||
indentString = indentString.replace(/\t/g, this.getTabString());
|
||||
for (var row=startRow; row<=endRow; row++) {
|
||||
this.insert({row: row, column:0}, indentString);
|
||||
}
|
||||
return indentString.length;
|
||||
};
|
||||
|
||||
this.outdentRows = function (range) {
|
||||
var rowRange = range.collapseRows();
|
||||
var deleteRange = new Range(0, 0, 0, 0);
|
||||
var size = this.getTabSize();
|
||||
|
||||
for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
|
||||
var line = this.getLine(i);
|
||||
|
||||
deleteRange.start.row = i;
|
||||
deleteRange.end.row = i;
|
||||
for (var j = 0; j < size; ++j)
|
||||
if (line.charAt(j) != ' ')
|
||||
break;
|
||||
if (j < size && line.charAt(j) == '\t') {
|
||||
deleteRange.start.column = j;
|
||||
deleteRange.end.column = j + 1;
|
||||
} else {
|
||||
deleteRange.start.column = 0;
|
||||
deleteRange.end.column = j;
|
||||
}
|
||||
if (i == range.start.row)
|
||||
range.start.column -= deleteRange.end.column - deleteRange.start.column;
|
||||
if (i == range.end.row)
|
||||
range.end.column -= deleteRange.end.column - deleteRange.start.column;
|
||||
this.remove(deleteRange);
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
this.moveLinesUp = function(firstRow, lastRow) {
|
||||
if (firstRow <= 0) return 0;
|
||||
|
||||
var removed = this.doc.removeLines(firstRow, lastRow);
|
||||
this.doc.insertLines(firstRow - 1, removed);
|
||||
return -1;
|
||||
};
|
||||
|
||||
this.moveLinesDown = function(firstRow, lastRow) {
|
||||
if (lastRow >= this.doc.getLength()-1) return 0;
|
||||
|
||||
var removed = this.doc.removeLines(firstRow, lastRow);
|
||||
this.doc.insertLines(firstRow+1, removed);
|
||||
return 1;
|
||||
};
|
||||
|
||||
this.duplicateLines = function(firstRow, lastRow) {
|
||||
var firstRow = this.$clipRowToDocument(firstRow);
|
||||
var lastRow = this.$clipRowToDocument(lastRow);
|
||||
|
||||
var lines = this.getLines(firstRow, lastRow);
|
||||
this.doc.insertLines(firstRow, lines);
|
||||
|
||||
var addedRows = lastRow - firstRow + 1;
|
||||
return addedRows;
|
||||
};
|
||||
|
||||
this.$clipRowToDocument = function(row) {
|
||||
return Math.max(0, Math.min(row, this.doc.getLength()-1));
|
||||
};
|
||||
|
||||
this.documentToScreenColumn = function(row, docColumn) {
|
||||
var tabSize = this.getTabSize();
|
||||
|
||||
var screenColumn = 0;
|
||||
var remaining = docColumn;
|
||||
|
||||
var line = this.getLine(row).split("\t");
|
||||
for (var i=0; i<line.length; i++) {
|
||||
var len = line[i].length;
|
||||
if (remaining > len) {
|
||||
remaining -= (len + 1);
|
||||
screenColumn += len + tabSize;
|
||||
}
|
||||
else {
|
||||
screenColumn += remaining;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return screenColumn;
|
||||
};
|
||||
|
||||
this.screenToDocumentColumn = function(row, screenColumn) {
|
||||
var tabSize = this.getTabSize();
|
||||
|
||||
var docColumn = 0;
|
||||
var remaining = screenColumn;
|
||||
|
||||
var line = this.getLine(row).split("\t");
|
||||
for (var i=0; i<line.length; i++) {
|
||||
var len = line[i].length;
|
||||
if (remaining >= len + tabSize) {
|
||||
remaining -= (len + tabSize);
|
||||
docColumn += (len + 1);
|
||||
}
|
||||
else if (remaining > len){
|
||||
docColumn += len;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
docColumn += remaining;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return docColumn;
|
||||
};
|
||||
|
||||
}).call(EditSession.prototype);
|
||||
|
||||
exports.EditSession = EditSession;
|
||||
});
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -40,21 +40,21 @@ define(function(require, exports, module) {
|
|||
var oop = require("pilot/oop");
|
||||
var event = require("pilot/event");
|
||||
var lang = require("pilot/lang");
|
||||
var TextInput = require("ace/textinput").TextInput;
|
||||
var KeyBinding = require("ace/keybinding").KeyBinding;
|
||||
var Document = require("ace/document").Document;
|
||||
var TextInput = require("ace/keyboard/textinput").TextInput;
|
||||
var KeyBinding = require("ace/keyboard/keybinding").KeyBinding;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var Search = require("ace/search").Search;
|
||||
var BackgroundTokenizer = require("ace/background_tokenizer").BackgroundTokenizer;
|
||||
var Range = require("ace/range").Range;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
|
||||
var Editor =function(renderer, doc) {
|
||||
var Editor =function(renderer, session) {
|
||||
var container = renderer.getContainerElement();
|
||||
this.container = container;
|
||||
this.renderer = renderer;
|
||||
|
||||
this.textInput = new TextInput(container, this);
|
||||
this.keyBinding = new KeyBinding(container, this);
|
||||
this.keyBinding = new KeyBinding(this);
|
||||
var self = this;
|
||||
event.addListener(container, "mousedown", function(e) {
|
||||
setTimeout(function() {self.focus();});
|
||||
|
|
@ -64,7 +64,7 @@ var Editor =function(renderer, doc) {
|
|||
return event.preventDefault(e);
|
||||
});
|
||||
|
||||
var mouseTarget = renderer.getMouseEventTarget();
|
||||
var mouseTarget = renderer.getMouseEventTarget();
|
||||
event.addListener(mouseTarget, "mousedown", this.onMouseDown.bind(this));
|
||||
event.addMultiMouseDownListener(mouseTarget, 0, 2, 500, this.onMouseDoubleClick.bind(this));
|
||||
event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, this.onMouseTripleClick.bind(this));
|
||||
|
|
@ -78,7 +78,7 @@ var Editor =function(renderer, doc) {
|
|||
wrap: true
|
||||
});
|
||||
|
||||
this.setDocument(doc || new Document(""));
|
||||
this.setSession(session || new EditSession(""));
|
||||
this.focus();
|
||||
};
|
||||
|
||||
|
|
@ -110,38 +110,46 @@ var Editor =function(renderer, doc) {
|
|||
}
|
||||
};
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
if (this.doc == doc) return;
|
||||
this.setKeyboardHandler = function(keyboardHandler) {
|
||||
this.keyBinding.setKeyboardHandler(keyboardHandler);
|
||||
};
|
||||
|
||||
if (this.doc) {
|
||||
this.doc.removeEventListener("change", this.$onDocumentChange);
|
||||
this.doc.removeEventListener("changeMode", this.$onDocumentModeChange);
|
||||
this.doc.removeEventListener("changeTabSize", this.$onDocumentChangeTabSize);
|
||||
this.doc.removeEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
|
||||
this.getKeyboardHandler = function() {
|
||||
return this.keyBinding.getKeyboardHandler();
|
||||
}
|
||||
|
||||
var selection = this.doc.getSelection();
|
||||
this.setSession = function(session) {
|
||||
if (this.session == session) return;
|
||||
|
||||
if (this.session) {
|
||||
this.session.removeEventListener("change", this.$onDocumentChange);
|
||||
this.session.removeEventListener("changeMode", this.$onDocumentModeChange);
|
||||
this.session.removeEventListener("changeTabSize", this.$onDocumentChangeTabSize);
|
||||
this.session.removeEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
|
||||
|
||||
var selection = this.session.getSelection();
|
||||
selection.removeEventListener("changeCursor", this.$onCursorChange);
|
||||
selection.removeEventListener("changeSelection", this.$onSelectionChange);
|
||||
|
||||
this.doc.setScrollTopRow(this.renderer.getScrollTopRow());
|
||||
this.session.setScrollTopRow(this.renderer.getScrollTopRow());
|
||||
}
|
||||
|
||||
this.doc = doc;
|
||||
this.session = session;
|
||||
|
||||
this.$onDocumentChange = this.onDocumentChange.bind(this);
|
||||
doc.addEventListener("change", this.$onDocumentChange);
|
||||
this.renderer.setDocument(doc);
|
||||
session.addEventListener("change", this.$onDocumentChange);
|
||||
this.renderer.setSession(session);
|
||||
|
||||
this.$onDocumentModeChange = this.onDocumentModeChange.bind(this);
|
||||
doc.addEventListener("changeMode", this.$onDocumentModeChange);
|
||||
session.addEventListener("changeMode", this.$onDocumentModeChange);
|
||||
|
||||
this.$onDocumentChangeTabSize = this.renderer.updateText.bind(this.renderer);
|
||||
doc.addEventListener("changeTabSize", this.$onDocumentChangeTabSize);
|
||||
session.addEventListener("changeTabSize", this.$onDocumentChangeTabSize);
|
||||
|
||||
this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this);
|
||||
this.doc.addEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
|
||||
this.session.addEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
|
||||
|
||||
this.selection = doc.getSelection();
|
||||
this.selection = session.getSelection();
|
||||
this.$desiredColumn = 0;
|
||||
|
||||
this.$onCursorChange = this.onCursorChange.bind(this);
|
||||
|
|
@ -151,18 +159,18 @@ var Editor =function(renderer, doc) {
|
|||
this.selection.addEventListener("changeSelection", this.$onSelectionChange);
|
||||
|
||||
this.onDocumentModeChange();
|
||||
this.bgTokenizer.setLines(this.doc.lines);
|
||||
this.bgTokenizer.setDocument(session.getDocument());
|
||||
this.bgTokenizer.start(0);
|
||||
|
||||
this.onCursorChange();
|
||||
this.onSelectionChange();
|
||||
this.onDocumentChangeBreakpoint();
|
||||
this.renderer.scrollToRow(doc.getScrollTopRow());
|
||||
this.renderer.scrollToRow(session.getScrollTopRow());
|
||||
this.renderer.updateFull();
|
||||
};
|
||||
|
||||
this.getDocument = function() {
|
||||
return this.doc;
|
||||
this.getSession = function() {
|
||||
return this.session;
|
||||
};
|
||||
|
||||
this.getSelection = function() {
|
||||
|
|
@ -193,7 +201,7 @@ var Editor =function(renderer, doc) {
|
|||
setTimeout(function() {
|
||||
self.$highlightPending = false;
|
||||
|
||||
var pos = self.doc.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);
|
||||
self.$bracketHighlight = self.renderer.addMarker(range, "ace_bracket");
|
||||
|
|
@ -220,9 +228,15 @@ var Editor =function(renderer, doc) {
|
|||
};
|
||||
|
||||
this.onDocumentChange = function(e) {
|
||||
var data = e.data;
|
||||
this.bgTokenizer.start(data.firstRow);
|
||||
this.renderer.updateLines(data.firstRow, data.lastRow);
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
|
||||
this.bgTokenizer.start(range.start.row);
|
||||
if (range.start.row == range.end.row)
|
||||
var lastRow = range.end.row;
|
||||
else
|
||||
lastRow = Infinity;
|
||||
this.renderer.updateLines(range.start.row, lastRow);
|
||||
|
||||
// update cursor because tab characters can influence the cursor position
|
||||
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
|
||||
|
|
@ -233,11 +247,11 @@ var Editor =function(renderer, doc) {
|
|||
this.renderer.updateLines(rows.first, rows.last);
|
||||
};
|
||||
|
||||
this.onCursorChange = function() {
|
||||
this.onCursorChange = function(e) {
|
||||
this.$highlightBrackets();
|
||||
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
|
||||
|
||||
if (!this.$blockScrolling) {
|
||||
if (!this.$blockScrolling && (!e || !e.blockScrolling)) {
|
||||
this.renderer.scrollCursorIntoView();
|
||||
}
|
||||
this.$updateHighlightActiveLine();
|
||||
|
|
@ -256,7 +270,7 @@ var Editor =function(renderer, doc) {
|
|||
}
|
||||
};
|
||||
|
||||
this.onSelectionChange = function() {
|
||||
this.onSelectionChange = function(e) {
|
||||
if (this.$selectionMarker) {
|
||||
this.renderer.removeMarker(this.$selectionMarker);
|
||||
}
|
||||
|
|
@ -268,15 +282,15 @@ var Editor =function(renderer, doc) {
|
|||
this.$selectionMarker = this.renderer.addMarker(range, "ace_selection", style);
|
||||
}
|
||||
|
||||
this.onCursorChange();
|
||||
this.onCursorChange(e);
|
||||
};
|
||||
|
||||
this.onDocumentChangeBreakpoint = function() {
|
||||
this.renderer.setBreakpoints(this.doc.getBreakpoints());
|
||||
this.renderer.setBreakpoints(this.session.getBreakpoints());
|
||||
};
|
||||
|
||||
this.onDocumentModeChange = function() {
|
||||
var mode = this.doc.getMode();
|
||||
var mode = this.session.getMode();
|
||||
if (this.mode == mode)
|
||||
return;
|
||||
|
||||
|
|
@ -300,7 +314,7 @@ var Editor =function(renderer, doc) {
|
|||
var pageY = event.getDocumentY(e);
|
||||
|
||||
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
||||
pos.row = Math.max(0, Math.min(pos.row, this.doc.getLength()-1));
|
||||
pos.row = Math.max(0, Math.min(pos.row, this.session.getLength()-1));
|
||||
|
||||
if (event.getButton(e) != 0) {
|
||||
if (this.selection.isEmpty()) {
|
||||
|
|
@ -337,7 +351,7 @@ var Editor =function(renderer, doc) {
|
|||
return;
|
||||
|
||||
var cursor = self.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||
cursor.row = Math.max(0, Math.min(cursor.row, self.doc.getLength()-1));
|
||||
cursor.row = Math.max(0, Math.min(cursor.row, self.session.getLength()-1));
|
||||
|
||||
if (self.$clickSelection) {
|
||||
if (self.$clickSelection.contains(cursor.row, cursor.column)) {
|
||||
|
|
@ -386,7 +400,7 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
this.getCopyText = function() {
|
||||
if (!this.selection.isEmpty()) {
|
||||
return this.doc.getTextRange(this.getSelectionRange());
|
||||
return this.session.getTextRange(this.getSelectionRange());
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
|
|
@ -398,88 +412,93 @@ var Editor =function(renderer, doc) {
|
|||
return;
|
||||
|
||||
if (!this.selection.isEmpty()) {
|
||||
this.moveCursorToPosition(this.doc.remove(this.getSelectionRange()));
|
||||
this.moveCursorToPosition(this.session.remove(this.getSelectionRange()));
|
||||
this.clearSelection();
|
||||
}
|
||||
};
|
||||
|
||||
this.onTextInput = function(text) {
|
||||
this.insert = function(text) {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
text = text.replace("\t", this.doc.getTabString());
|
||||
text = text.replace("\t", this.session.getTabString());
|
||||
|
||||
// remove selected text
|
||||
if (!this.selection.isEmpty()) {
|
||||
var cursor = this.doc.remove(this.getSelectionRange());
|
||||
var cursor = this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
} else if (this.$overwrite){
|
||||
var range = new Range.fromPoints(cursor, cursor);
|
||||
range.end.column += text.length;
|
||||
this.doc.remove(range);
|
||||
this.session.remove(range);
|
||||
}
|
||||
|
||||
this.clearSelection();
|
||||
|
||||
var _self = this;
|
||||
this.bgTokenizer.getState(cursor.row, function (lineState) {
|
||||
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(cursor.row), text);
|
||||
var line = _self.doc.getLine(cursor.row),
|
||||
lineIndent = _self.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), _self.doc.getTabString());
|
||||
var end = _self.doc.insert(cursor, text);
|
||||
var lineState = this.bgTokenizer.getState(cursor.row);
|
||||
var shouldOutdent = this.mode.checkOutdent(lineState, this.session.getLine(cursor.row), text);
|
||||
var line = this.session.getLine(cursor.row);
|
||||
var lineIndent = this.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), this.session.getTabString());
|
||||
var end = this.session.insert(cursor, text);
|
||||
|
||||
/* TODO: This shortcut is somehow broken
|
||||
if (!shouldOutdent && line != _self.doc.getLine(row) && text != "\n") {
|
||||
_self.moveCursorToPosition(end);
|
||||
_self.renderer.scrollCursorIntoView();
|
||||
return;
|
||||
/* TODO: This shortcut is somehow broken
|
||||
if (!shouldOutdent && line != this.session.getLine(row) && text != "\n") {
|
||||
this.moveCursorToPosition(end);
|
||||
this.renderer.scrollCursorIntoView();
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
var lineState = this.bgTokenizer.getState(cursor.row);
|
||||
// multi line insert
|
||||
if (cursor.row !== end.row) {
|
||||
var size = this.session.getTabSize(),
|
||||
minIndent = Number.MAX_VALUE;
|
||||
|
||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||
var indent = 0;
|
||||
|
||||
line = this.session.getLine(row);
|
||||
for (var i = 0; i < line.length; ++i)
|
||||
if (line.charAt(i) == '\t')
|
||||
indent += size;
|
||||
else if (line.charAt(i) == ' ')
|
||||
indent += 1;
|
||||
else
|
||||
break;
|
||||
if (/[^\s]/.test(line))
|
||||
minIndent = Math.min(indent, minIndent);
|
||||
}
|
||||
*/
|
||||
|
||||
_self.bgTokenizer.getState(cursor.row, function(lineState) {
|
||||
// multi line insert
|
||||
if (cursor.row !== end.row) {
|
||||
var size = _self.doc.getTabSize(),
|
||||
minIndent = Number.MAX_VALUE;
|
||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||
var outdent = minIndent;
|
||||
|
||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||
var indent = 0;
|
||||
line = this.session.getLine(row);
|
||||
for (var i = 0; i < line.length && outdent > 0; ++i)
|
||||
if (line.charAt(i) == '\t')
|
||||
outdent -= size;
|
||||
else if (line.charAt(i) == ' ')
|
||||
outdent -= 1;
|
||||
this.session.replace(new Range(row, 0, row, line.length), line.substr(i));
|
||||
}
|
||||
end.column += this.session.indentRows(cursor.row + 1, end.row, lineIndent);
|
||||
} else {
|
||||
if (shouldOutdent) {
|
||||
end.column += this.mode.autoOutdent(lineState, this.session, cursor.row);
|
||||
}
|
||||
}
|
||||
|
||||
line = _self.doc.getLine(row);
|
||||
for (var i = 0; i < line.length; ++i)
|
||||
if (line.charAt(i) == '\t')
|
||||
indent += size;
|
||||
else if (line.charAt(i) == ' ')
|
||||
indent += 1;
|
||||
else
|
||||
break;
|
||||
if (/[^\s]/.test(line))
|
||||
minIndent = Math.min(indent, minIndent);
|
||||
}
|
||||
this.moveCursorToPosition(end);
|
||||
this.renderer.scrollCursorIntoView();
|
||||
}
|
||||
|
||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||
var outdent = minIndent;
|
||||
this.onTextInput = function(text) {
|
||||
this.keyBinding.onTextInput(text);
|
||||
};
|
||||
|
||||
line = _self.doc.getLine(row);
|
||||
for (var i = 0; i < line.length && outdent > 0; ++i)
|
||||
if (line.charAt(i) == '\t')
|
||||
outdent -= size;
|
||||
else if (line.charAt(i) == ' ')
|
||||
outdent -= 1;
|
||||
_self.doc.replace(new Range(row, 0, row, line.length), line.substr(i));
|
||||
}
|
||||
end.column += _self.doc.indentRows(cursor.row + 1, end.row, lineIndent);
|
||||
} else {
|
||||
if (shouldOutdent) {
|
||||
end.column += _self.mode.autoOutdent(lineState, _self.doc, cursor.row);
|
||||
}
|
||||
}
|
||||
|
||||
_self.moveCursorToPosition(end);
|
||||
_self.renderer.scrollCursorIntoView();
|
||||
});
|
||||
});
|
||||
this.onCommandKey = function(e, hashId, keyCode) {
|
||||
this.keyBinding.onCommandKey(e, hashId, keyCode);
|
||||
};
|
||||
|
||||
this.$overwrite = false;
|
||||
|
|
@ -582,7 +601,7 @@ var Editor =function(renderer, doc) {
|
|||
if (this.selection.isEmpty()) {
|
||||
this.selection.selectRight();
|
||||
}
|
||||
this.moveCursorToPosition(this.doc.remove(this.getSelectionRange()));
|
||||
this.moveCursorToPosition(this.session.remove(this.getSelectionRange()));
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
|
@ -592,8 +611,8 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
if (this.selection.isEmpty())
|
||||
this.selection.selectLeft();
|
||||
|
||||
this.moveCursorToPosition(this.doc.remove(this.getSelectionRange()));
|
||||
|
||||
this.moveCursorToPosition(this.session.remove(this.getSelectionRange()));
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
|
@ -601,21 +620,21 @@ var Editor =function(renderer, doc) {
|
|||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
var doc = this.doc,
|
||||
range = this.getSelectionRange();
|
||||
var session = this.session;
|
||||
var range = this.getSelectionRange();
|
||||
|
||||
if (range.start.row < range.end.row || range.start.column < range.end.column) {
|
||||
var rows = this.$getSelectedRows();
|
||||
var count = doc.indentRows(rows.first, rows.last, "\t");
|
||||
var count = session.indentRows(rows.first, rows.last, "\t");
|
||||
|
||||
this.selection.shiftSelection(count);
|
||||
} else {
|
||||
var indentString;
|
||||
|
||||
if (this.doc.getUseSoftTabs()) {
|
||||
var size = doc.getTabSize(),
|
||||
if (this.session.getUseSoftTabs()) {
|
||||
var size = session.getTabSize(),
|
||||
position = this.getCursorPosition(),
|
||||
column = doc.documentToScreenColumn(position.row, position.column),
|
||||
column = session.documentToScreenColumn(position.row, position.column),
|
||||
count = (size - column % size);
|
||||
|
||||
indentString = lang.stringRepeat(" ", count);
|
||||
|
|
@ -629,8 +648,8 @@ var Editor =function(renderer, doc) {
|
|||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
var selection = this.doc.getSelection();
|
||||
var range = this.doc.outdentRows(selection.getRange());
|
||||
var selection = this.session.getSelection();
|
||||
var range = this.session.outdentRows(selection.getRange());
|
||||
|
||||
selection.setSelectionRange(range, selection.isBackwards());
|
||||
this.$updateDesiredColumn();
|
||||
|
|
@ -640,12 +659,10 @@ var Editor =function(renderer, doc) {
|
|||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
var _self = this;
|
||||
this.bgTokenizer.getState(this.getCursorPosition().row, function(state) {
|
||||
var rows = _self.$getSelectedRows()
|
||||
var addedColumns = _self.mode.toggleCommentLines(state, _self.doc, rows.first, rows.last);
|
||||
_self.selection.shiftSelection(addedColumns);
|
||||
});
|
||||
var state = this.bgTokenizer.getState(this.getCursorPosition().row);
|
||||
var rows = this.$getSelectedRows()
|
||||
var addedColumns = this.mode.toggleCommentLines(state, this.session, rows.first, rows.last);
|
||||
this.selection.shiftSelection(addedColumns);
|
||||
};
|
||||
|
||||
this.removeLines = function() {
|
||||
|
|
@ -656,7 +673,7 @@ var Editor =function(renderer, doc) {
|
|||
this.selection.setSelectionAnchor(rows.last+1, 0);
|
||||
this.selection.selectTo(rows.first, 0);
|
||||
|
||||
this.doc.remove(this.getSelectionRange());
|
||||
this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
|
@ -665,7 +682,7 @@ var Editor =function(renderer, doc) {
|
|||
return;
|
||||
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.doc.moveLinesDown(firstRow, lastRow);
|
||||
return this.session.moveLinesDown(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -674,7 +691,7 @@ var Editor =function(renderer, doc) {
|
|||
return;
|
||||
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.doc.moveLinesUp(firstRow, lastRow);
|
||||
return this.session.moveLinesUp(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -683,7 +700,7 @@ var Editor =function(renderer, doc) {
|
|||
return;
|
||||
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
this.doc.duplicateLines(firstRow, lastRow);
|
||||
this.session.duplicateLines(firstRow, lastRow);
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
|
@ -693,7 +710,7 @@ var Editor =function(renderer, doc) {
|
|||
return;
|
||||
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.doc.duplicateLines(firstRow, lastRow);
|
||||
return this.session.duplicateLines(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -787,7 +804,7 @@ var Editor =function(renderer, doc) {
|
|||
this.gotoPageDown = function() {
|
||||
var row = this.getPageDownRow(),
|
||||
column = Math.min(this.getCursorPosition().column,
|
||||
this.doc.getLine(row).length);
|
||||
this.session.getLine(row).length);
|
||||
|
||||
this.scrollToRow(row);
|
||||
this.getSelection().moveCursorTo(row, column);
|
||||
|
|
@ -796,7 +813,7 @@ var Editor =function(renderer, doc) {
|
|||
this.gotoPageUp = function() {
|
||||
var row = this.getPageUpRow(),
|
||||
column = Math.min(this.getCursorPosition().column,
|
||||
this.doc.getLine(row).length);
|
||||
this.session.getLine(row).length);
|
||||
|
||||
this.scrollToRow(row);
|
||||
this.getSelection().moveCursorTo(row, column);
|
||||
|
|
@ -857,51 +874,57 @@ var Editor =function(renderer, doc) {
|
|||
this.$updateDesiredColumn(column);
|
||||
};
|
||||
|
||||
this.navigateUp = function() {
|
||||
this.navigateUp = function(times) {
|
||||
this.selection.clearSelection();
|
||||
this.selection.moveCursorBy(-1, 0);
|
||||
this.selection.moveCursorBy(-(times || 1), 0);
|
||||
|
||||
if (this.$desiredColumn) {
|
||||
var cursor = this.getCursorPosition();
|
||||
var column = this.doc.screenToDocumentColumn(cursor.row, this.$desiredColumn);
|
||||
var column = this.session.screenToDocumentColumn(cursor.row, this.$desiredColumn);
|
||||
this.selection.moveCursorTo(cursor.row, column);
|
||||
}
|
||||
};
|
||||
|
||||
this.navigateDown = function() {
|
||||
this.navigateDown = function(times) {
|
||||
this.selection.clearSelection();
|
||||
this.selection.moveCursorBy(1, 0);
|
||||
this.selection.moveCursorBy(times || 1, 0);
|
||||
|
||||
if (this.$desiredColumn) {
|
||||
var cursor = this.getCursorPosition();
|
||||
var column = this.doc.screenToDocumentColumn(cursor.row, this.$desiredColumn);
|
||||
var column = this.session.screenToDocumentColumn(cursor.row, this.$desiredColumn);
|
||||
this.selection.moveCursorTo(cursor.row, column);
|
||||
}
|
||||
};
|
||||
|
||||
this.$updateDesiredColumn = function() {
|
||||
var cursor = this.getCursorPosition();
|
||||
this.$desiredColumn = this.doc.documentToScreenColumn(cursor.row, cursor.column);
|
||||
this.$desiredColumn = this.session.documentToScreenColumn(cursor.row, cursor.column);
|
||||
};
|
||||
|
||||
this.navigateLeft = function() {
|
||||
this.navigateLeft = function(times) {
|
||||
if (!this.selection.isEmpty()) {
|
||||
var selectionStart = this.getSelectionRange().start;
|
||||
this.moveCursorToPosition(selectionStart);
|
||||
}
|
||||
else {
|
||||
this.selection.moveCursorLeft();
|
||||
times = times || 1;
|
||||
while (times--) {
|
||||
this.selection.moveCursorLeft();
|
||||
}
|
||||
}
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
this.navigateRight = function() {
|
||||
this.navigateRight = function(times) {
|
||||
if (!this.selection.isEmpty()) {
|
||||
var selectionEnd = this.getSelectionRange().end;
|
||||
this.moveCursorToPosition(selectionEnd);
|
||||
}
|
||||
else {
|
||||
this.selection.moveCursorRight();
|
||||
times = times || 1;
|
||||
while (times--) {
|
||||
this.selection.moveCursorRight();
|
||||
}
|
||||
}
|
||||
this.clearSelection();
|
||||
};
|
||||
|
|
@ -940,7 +963,7 @@ var Editor =function(renderer, doc) {
|
|||
if (options)
|
||||
this.$search.set(options);
|
||||
|
||||
var range = this.$search.find(this.doc);
|
||||
var range = this.$search.find(this.session);
|
||||
this.$tryReplace(range, replacement);
|
||||
if (range !== null)
|
||||
this.selection.setSelectionRange(range);
|
||||
|
|
@ -952,7 +975,7 @@ var Editor =function(renderer, doc) {
|
|||
this.$search.set(options);
|
||||
}
|
||||
|
||||
var ranges = this.$search.findAll(this.doc);
|
||||
var ranges = this.$search.findAll(this.session);
|
||||
if (!ranges.length)
|
||||
return;
|
||||
|
||||
|
|
@ -967,10 +990,10 @@ var Editor =function(renderer, doc) {
|
|||
},
|
||||
|
||||
this.$tryReplace = function(range, replacement) {
|
||||
var input = this.doc.getTextRange(range);
|
||||
var input = this.session.getTextRange(range);
|
||||
var replacement = this.$search.replace(input, replacement);
|
||||
if (replacement !== null) {
|
||||
range.end = this.doc.replace(range, replacement);
|
||||
range.end = this.session.replace(range, replacement);
|
||||
return range;
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -1007,13 +1030,13 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
this.$find = function(backwards) {
|
||||
if (!this.selection.isEmpty()) {
|
||||
this.$search.set({needle: this.doc.getTextRange(this.getSelectionRange())});
|
||||
this.$search.set({needle: this.session.getTextRange(this.getSelectionRange())});
|
||||
}
|
||||
|
||||
if (typeof backwards != "undefined")
|
||||
this.$search.set({backwards: backwards});
|
||||
|
||||
var range = this.$search.find(this.doc);
|
||||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.gotoLine(range.end.row+1, range.end.column);
|
||||
this.$updateDesiredColumn();
|
||||
|
|
@ -1022,11 +1045,11 @@ var Editor =function(renderer, doc) {
|
|||
};
|
||||
|
||||
this.undo = function() {
|
||||
this.doc.getUndoManager().undo();
|
||||
this.session.getUndoManager().undo();
|
||||
};
|
||||
|
||||
this.redo = function() {
|
||||
this.doc.getUndoManager().redo();
|
||||
this.session.getUndoManager().redo();
|
||||
};
|
||||
|
||||
}).call(Editor.prototype);
|
||||
|
|
|
|||
|
|
@ -11,15 +11,16 @@
|
|||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
* The Original Code is Mozilla Skywriter.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Julian Viereck (julian.viereck@gmail.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -37,72 +38,13 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var useragent = require("pilot/useragent");
|
||||
var event = require("pilot/event");
|
||||
var default_mac = require("ace/conf/keybindings/default_mac").bindings;
|
||||
var default_win = require("ace/conf/keybindings/default_win").bindings;
|
||||
var canon = require("pilot/canon");
|
||||
require("ace/commands/default_commands");
|
||||
var keyUtil = require("pilot/keys");
|
||||
|
||||
var KeyBinding = function(element, editor, config) {
|
||||
function HashHandler(config) {
|
||||
this.setConfig(config);
|
||||
|
||||
var _self = this;
|
||||
event.addKeyListener(element, function(e) {
|
||||
// opera on mac swaps ctrl and meta keys
|
||||
if (useragent.isOpera && useragent.isMac)
|
||||
var hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0)
|
||||
| (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
|
||||
else
|
||||
var hashId = 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0)
|
||||
| (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
|
||||
|
||||
var key = _self.keyNames[e.keyCode];
|
||||
|
||||
var commandName = (_self.config.reverse[hashId] || {})[(key
|
||||
|| String.fromCharCode(e.keyCode)).toLowerCase()];
|
||||
|
||||
var success = canon.exec(commandName, {editor: editor});
|
||||
if (success) {
|
||||
return event.stopEvent(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
(function() {
|
||||
this.keyMods = {"ctrl": 1, "alt": 2, "option" : 2, "shift": 4, "meta": 8, "command": 8};
|
||||
|
||||
this.keyNames = {
|
||||
"8" : "Backspace",
|
||||
"9" : "Tab",
|
||||
"13" : "Enter",
|
||||
"27" : "Esc",
|
||||
"32" : "Space",
|
||||
"33" : "PageUp",
|
||||
"34" : "PageDown",
|
||||
"35" : "End",
|
||||
"36" : "Home",
|
||||
"37" : "Left",
|
||||
"38" : "Up",
|
||||
"39" : "Right",
|
||||
"40" : "Down",
|
||||
"45" : "Insert",
|
||||
"46" : "Delete",
|
||||
"107": "+",
|
||||
"112": "F1",
|
||||
"113": "F2",
|
||||
"114": "F3",
|
||||
"115": "F4",
|
||||
"116": "F5",
|
||||
"117": "F6",
|
||||
"118": "F7",
|
||||
"119": "F8",
|
||||
"120": "F9",
|
||||
"121": "F10",
|
||||
"122": "F11",
|
||||
"123": "F12"
|
||||
};
|
||||
|
||||
function splitSafe(s, separator, limit, bLowerCase) {
|
||||
return (bLowerCase && s.toLowerCase() || s)
|
||||
.replace(/(?:^\s+|\n|\s+$)/g, "")
|
||||
|
|
@ -117,8 +59,8 @@ var KeyBinding = function(element, editor, config) {
|
|||
l = parts.length;
|
||||
|
||||
for (; i < l; ++i) {
|
||||
if (this.keyMods[parts[i]])
|
||||
hashId = hashId | this.keyMods[parts[i]];
|
||||
if (keyUtil.KEY_MODS[parts[i]])
|
||||
hashId = hashId | keyUtil.KEY_MODS[parts[i]];
|
||||
else
|
||||
key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
|
||||
}
|
||||
|
|
@ -145,14 +87,30 @@ var KeyBinding = function(element, editor, config) {
|
|||
}
|
||||
|
||||
this.setConfig = function(config) {
|
||||
this.config = config || (useragent.isMac
|
||||
? default_mac
|
||||
: default_win);
|
||||
if (typeof this.config.reverse == "undefined")
|
||||
this.config.reverse = objectReverse.call(this, this.config, "|");
|
||||
this.$config = config;
|
||||
if (typeof this.$config.reverse == "undefined")
|
||||
this.$config.reverse = objectReverse.call(this, this.$config, "|");
|
||||
};
|
||||
|
||||
}).call(KeyBinding.prototype);
|
||||
/**
|
||||
* This function is called by keyBinding.
|
||||
*/
|
||||
this.handleKeyboard = function(data, hashId, textOrKey, keyCode) {
|
||||
// Figure out if a commandKey was pressed or just some text was insert.
|
||||
if (hashId != 0 || keyCode != 0) {
|
||||
return {
|
||||
command: (this.$config.reverse[hashId] || {})[textOrKey]
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
command: "inserttext",
|
||||
args: {
|
||||
text: textOrKey
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).call(HashHandler.prototype)
|
||||
|
||||
exports.KeyBinding = KeyBinding;
|
||||
exports.HashHandler = HashHandler;
|
||||
});
|
||||
108
lib/ace/keyboard/keybinding.js
Normal file
108
lib/ace/keyboard/keybinding.js
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Julian Viereck <julian.viereck@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var useragent = require("pilot/useragent");
|
||||
var keyUtil = require("pilot/keys");
|
||||
var event = require("pilot/event");
|
||||
var settings = require("pilot/settings").settings;
|
||||
var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
|
||||
var default_mac = require("ace/keyboard/keybinding/default_mac").bindings;
|
||||
var default_win = require("ace/keyboard/keybinding/default_win").bindings;
|
||||
var canon = require("pilot/canon");
|
||||
require("ace/commands/default_commands");
|
||||
|
||||
var KeyBinding = function(editor, config) {
|
||||
this.$editor = editor;
|
||||
this.$data = { };
|
||||
this.$keyboardHandler = null;
|
||||
this.$defaulKeyboardHandler = new HashHandler(config || (useragent.isMac
|
||||
? default_mac
|
||||
: default_win));
|
||||
};
|
||||
|
||||
(function() {
|
||||
this.setKeyboardHandler = function(keyboardHandler) {
|
||||
if (this.$keyboardHandler != keyboardHandler) {
|
||||
this.$data = { };
|
||||
this.$keyboardHandler = keyboardHandler;
|
||||
}
|
||||
};
|
||||
|
||||
this.getKeyboardHandler = function() {
|
||||
return this.$keyboardHandler;
|
||||
};
|
||||
|
||||
this.$callKeyboardHandler = function (e, hashId, keyOrText, keyCode) {
|
||||
var toExecute;
|
||||
if (this.$keyboardHandler) {
|
||||
toExecute =
|
||||
this.$keyboardHandler.handleKeyboard(this.$data, hashId, keyOrText, keyCode, e);
|
||||
}
|
||||
|
||||
// If there is nothing to execute yet, then use the default keymapping.
|
||||
if (!toExecute || !toExecute.command) {
|
||||
toExecute = this.$defaulKeyboardHandler.
|
||||
handleKeyboard(this.$data, hashId, keyOrText, keyCode, e);
|
||||
}
|
||||
|
||||
if (toExecute) {
|
||||
var success = canon.exec(toExecute.command,
|
||||
{editor: this.$editor}, toExecute.args);
|
||||
if (success) {
|
||||
return event.stopEvent(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.onCommandKey = function(e, hashId, keyCode) {
|
||||
key = (keyUtil[keyCode] ||
|
||||
String.fromCharCode(keyCode)).toLowerCase();
|
||||
|
||||
this.$callKeyboardHandler(e, hashId, key, keyCode);
|
||||
};
|
||||
|
||||
this.onTextInput = function(text) {
|
||||
this.$callKeyboardHandler({}, 0, text, 0);
|
||||
}
|
||||
|
||||
}).call(KeyBinding.prototype);
|
||||
|
||||
exports.KeyBinding = KeyBinding;
|
||||
});
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -60,7 +60,7 @@ exports.bindings = {
|
|||
"selecttoend": "Command-Shift-Down",
|
||||
"gotoend": "Command-End|Command-Down",
|
||||
"selectdown": "Shift-Down",
|
||||
"godown": "Down",
|
||||
"golinedown": "Down",
|
||||
"selectwordleft": "Option-Shift-Left",
|
||||
"gotowordleft": "Option-Left",
|
||||
"selecttolinestart": "Command-Shift-Left",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -60,7 +60,7 @@ exports.bindings = {
|
|||
"selecttoend": "Alt-Shift-Down",
|
||||
"gotoend": "Ctrl-End|Ctrl-Down",
|
||||
"selectdown": "Shift-Down",
|
||||
"godown": "Down",
|
||||
"golinedown": "Down",
|
||||
"selectwordleft": "Ctrl-Shift-Left",
|
||||
"gotowordleft": "Ctrl-Left",
|
||||
"selecttolinestart": "Alt-Shift-Left",
|
||||
149
lib/ace/keyboard/keybinding/emacs.js
Normal file
149
lib/ace/keyboard/keybinding/emacs.js
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Skywriter.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Julian Viereck (julian.viereck@gmail.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var StateHandler = require("ace/keyboard/state_handler").StateHandler;
|
||||
var matchCharacterOnly = require("ace/keyboard/state_handler").matchCharacterOnly;
|
||||
|
||||
var emacsState = {
|
||||
start: [
|
||||
{
|
||||
key: "ctrl-x",
|
||||
then: "c-x"
|
||||
},
|
||||
{
|
||||
regex: [ "(?:command-([0-9]*))*", "(down|ctrl-n)" ],
|
||||
exec: "golinedown",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
regex: [ "(?:command-([0-9]*))*", "(right|ctrl-f)" ],
|
||||
exec: "gotoright",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
regex: [ "(?:command-([0-9]*))*", "(up|ctrl-p)" ],
|
||||
exec: "golineup",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
regex: [ "(?:command-([0-9]*))*", "(left|ctrl-b)" ],
|
||||
exec: "gotoleft",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
comment: "This binding matches all printable characters except numbers as long as they are no numbers and print them n times.",
|
||||
regex: [ "(?:command-([0-9]*))", "([^0-9]+)*" ],
|
||||
match: matchCharacterOnly,
|
||||
exec: "inserttext",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: "1"
|
||||
},
|
||||
{
|
||||
name: "text",
|
||||
match: 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
comment: "This binding matches numbers as long as there is no meta_number in the buffer.",
|
||||
regex: [ "(command-[0-9]*)*", "([0-9]+)" ],
|
||||
match: matchCharacterOnly,
|
||||
disallowMatches: [ 1 ],
|
||||
exec: "inserttext",
|
||||
params: [
|
||||
{
|
||||
name: "text",
|
||||
match: 2,
|
||||
type: "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
regex: [ "command-([0-9]*)", "(command-[0-9]|[0-9])" ],
|
||||
comment: "Stops execution if the regex /meta_[0-9]+/ matches to avoid resetting the buffer."
|
||||
}
|
||||
],
|
||||
"c-x": [
|
||||
{
|
||||
key: "ctrl-g",
|
||||
then: "start"
|
||||
},
|
||||
{
|
||||
key: "ctrl-s",
|
||||
exec: "save",
|
||||
then: "start"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
exports.Emacs = new StateHandler(emacsState);
|
||||
|
||||
});
|
||||
112
lib/ace/keyboard/keybinding/vim.js
Normal file
112
lib/ace/keyboard/keybinding/vim.js
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Skywriter.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Julian Viereck (julian.viereck@gmail.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var StateHandler = require("ace/keyboard/state_handler").StateHandler;
|
||||
var matchCharacterOnly = require("ace/keyboard/state_handler").matchCharacterOnly;
|
||||
|
||||
var vimStates = {
|
||||
start: [
|
||||
{
|
||||
key: "i",
|
||||
then: "insertMode"
|
||||
},
|
||||
{
|
||||
regex: [ "([0-9]*)", "(k|up)" ],
|
||||
exec: "golineup",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
regex: [ "([0-9]*)", "(j|down|enter)" ],
|
||||
exec: "golinedown",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
regex: [ "([0-9]*)", "(l|right)" ],
|
||||
exec: "gotoright",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
regex: [ "([0-9]*)", "(h|left)" ],
|
||||
exec: "gotoleft",
|
||||
params: [
|
||||
{
|
||||
name: "times",
|
||||
match: 1,
|
||||
type: "number",
|
||||
defaultValue: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
comment: "Catch some keyboard input to stop it here",
|
||||
match: matchCharacterOnly
|
||||
}
|
||||
],
|
||||
insertMode: [
|
||||
{
|
||||
key: "esc",
|
||||
then: "start"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
exports.Vim = new StateHandler(vimStates);
|
||||
|
||||
});
|
||||
239
lib/ace/keyboard/state_handler.js
Normal file
239
lib/ace/keyboard/state_handler.js
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Skywriter.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Julian Viereck (julian.viereck@gmail.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
// If you're developing a new keymapping and want to get an idea what's going
|
||||
// on, then enable debugging.
|
||||
var DEBUG = false;
|
||||
|
||||
function StateHandler(keymapping) {
|
||||
this.keymapping = this.$buildKeymappingRegex(keymapping);
|
||||
}
|
||||
|
||||
StateHandler.prototype = {
|
||||
/**
|
||||
* Build the RegExp from the keymapping as RegExp can't stored directly
|
||||
* in the metadata JSON and as the RegExp used to match the keys/buffer
|
||||
* need to be adapted.
|
||||
*/
|
||||
$buildKeymappingRegex: function(keymapping) {
|
||||
for (state in keymapping) {
|
||||
this.$buildBindingsRegex(keymapping[state]);
|
||||
}
|
||||
return keymapping;
|
||||
},
|
||||
|
||||
$buildBindingsRegex: function(bindings) {
|
||||
// Escape a given Regex string.
|
||||
bindings.forEach(function(binding) {
|
||||
if (binding.key) {
|
||||
binding.key = new RegExp('^' + binding.key + '$');
|
||||
} else if (Array.isArray(binding.regex)) {
|
||||
binding.key = new RegExp('^' + binding.regex[1] + '$');
|
||||
binding.regex = new RegExp(binding.regex.join('') + '$');
|
||||
} else if (binding.regex) {
|
||||
binding.regex = new RegExp(binding.regex + '$');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
$composeBuffer: function(data, hashId, key) {
|
||||
// Initialize the data object.
|
||||
if (data.state == null || data.buffer == null) {
|
||||
data.state = "start";
|
||||
data.buffer = "";
|
||||
}
|
||||
|
||||
var keyArray = [];
|
||||
if (hashId & 1) keyArray.push("Ctrl");
|
||||
if (hashId & 8) keyArray.push("Command");
|
||||
if (hashId & 2) keyArray.push("Option");
|
||||
if (hashId & 4) keyArray.push("Shift");
|
||||
if (key) keyArray.push(key);
|
||||
|
||||
var symbolicName = keyArray.join("-").toLowerCase();
|
||||
var bufferToUse = data.buffer + symbolicName;
|
||||
|
||||
// Don't add the symbolic name to the key buffer if the alt_ key is
|
||||
// part of the symbolic name. If it starts with alt_, this means
|
||||
// that the user hit an alt keycombo and there will be a single,
|
||||
// new character detected after this event, which then will be
|
||||
// added to the buffer (e.g. alt_j will result in ∆).
|
||||
//
|
||||
// We test for 2 and not for & 2 as we only want to exclude the case where
|
||||
// the option key is pressed alone.
|
||||
if (hashId != 2) {
|
||||
data.buffer = bufferToUse;
|
||||
}
|
||||
|
||||
return {
|
||||
bufferToUse: bufferToUse,
|
||||
symbolicName: symbolicName
|
||||
};
|
||||
},
|
||||
|
||||
$find: function(data, buffer, symbolicName, hashId, key) {
|
||||
// Holds the command to execute and the args if a command matched.
|
||||
var result = {};
|
||||
|
||||
// Loop over all the bindings of the keymapp until a match is found.
|
||||
this.keymapping[data.state].some(function(binding) {
|
||||
var match;
|
||||
|
||||
// Check if the key matches.
|
||||
if (binding.key && !binding.key.test(symbolicName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the regex matches.
|
||||
if (binding.regex && !(match = binding.regex.exec(buffer))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the match function matches.
|
||||
if (binding.match && !binding.match(buffer, hashId, key, symbolicName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for disallowed matches.
|
||||
if (binding.disallowMatches) {
|
||||
for (var i = 0; i < binding.disallowMatches.length; i++) {
|
||||
if (!!match[binding.disallowMatches[i]]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a command to execute, then figure out the
|
||||
// comand and the arguments.
|
||||
if (binding.exec) {
|
||||
result.command = binding.exec;
|
||||
|
||||
// Bulid the arguments.
|
||||
if (binding.params) {
|
||||
var value;
|
||||
result.args = {};
|
||||
binding.params.forEach(function(param) {
|
||||
if (param.match != null && match != null) {
|
||||
value = match[param.match] || param.defaultValue;
|
||||
} else {
|
||||
value = param.defaultValue;
|
||||
}
|
||||
|
||||
if (param.type === 'number') {
|
||||
value = parseInt(value);
|
||||
}
|
||||
|
||||
result.args[param.name] = value;
|
||||
});
|
||||
}
|
||||
data.buffer = "";
|
||||
}
|
||||
|
||||
// Handle the 'then' property.
|
||||
if (binding.then) {
|
||||
data.state = binding.then;
|
||||
data.buffer = "";
|
||||
}
|
||||
|
||||
// If no command is set, then execute the "null" fake command.
|
||||
if (result.command == null) {
|
||||
result.command = "null";
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
console.log("KeyboardStateMapper#find", binding);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (result.command) {
|
||||
return result;
|
||||
} else {
|
||||
data.buffer = "";
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This function is called by keyBinding.
|
||||
*/
|
||||
handleKeyboard: function(data, hashId, key) {
|
||||
// Compute the current value of the keyboard input buffer.
|
||||
var r = this.$composeBuffer(data, hashId, key);
|
||||
var buffer = r.bufferToUse;
|
||||
var symbolicName = r.symbolicName;
|
||||
|
||||
r = this.$find(data, buffer, symbolicName, hashId, key);
|
||||
if (DEBUG) {
|
||||
console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a useful matching function and therefore is defined here so that
|
||||
* users of KeyboardStateMapper can use it.
|
||||
*
|
||||
* @return boolean
|
||||
* If no command key (Command|Option|Shift|Ctrl) is pressed, it
|
||||
* returns true. If the only the Shift key is pressed + a character
|
||||
* true is returned as well. Otherwise, false is returned.
|
||||
* Summing up, the function returns true whenever the user typed
|
||||
* a normal character on the keyboard and no shortcut.
|
||||
*/
|
||||
exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) {
|
||||
// If no command keys are pressed, then catch the input.
|
||||
if (hashId == 0) {
|
||||
return true;
|
||||
}
|
||||
// If only the shift key is pressed and a character key, then
|
||||
// catch that input as well.
|
||||
else if ((hashId == 4) && key.length == 1) {
|
||||
return true;
|
||||
}
|
||||
// Otherwise, we let the input got through.
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
exports.StateHandler = StateHandler;
|
||||
});
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -54,9 +54,9 @@ var TextInput = function(parentNode, host) {
|
|||
var inCompostion = false;
|
||||
var copied = false;
|
||||
|
||||
function sendText() {
|
||||
function sendText(valueToSend) {
|
||||
if (!copied) {
|
||||
var value = text.value;
|
||||
var value = valueToSend || text.value;
|
||||
if (value) {
|
||||
if (value.charCodeAt(value.length-1) == PLACEHOLDER.charCodeAt(0)) {
|
||||
value = value.slice(0, -1);
|
||||
|
|
@ -114,9 +114,22 @@ var TextInput = function(parentNode, host) {
|
|||
setTimeout(sendText, 0);
|
||||
};
|
||||
|
||||
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
|
||||
event.addListener(text, "keypress", onTextInput);
|
||||
event.addListener(text, "textInput", onTextInput);
|
||||
event.addListener(text, "paste", onTextInput);
|
||||
event.addListener(text, "paste", function(e) {
|
||||
// Some browsers support the event.clipboardData API. Use this to get
|
||||
// the pasted content which increases speed if pasting a lot of lines.
|
||||
if (e.clipboardData && e.clipboardData.getData) {
|
||||
sendText(e.clipboardData.getData("text/plain"));
|
||||
e.preventDefault();
|
||||
} else
|
||||
// If a browser doesn't support any of the things above, use the regular
|
||||
// method to detect the pasted input.
|
||||
{
|
||||
onTextInput();
|
||||
}
|
||||
});
|
||||
event.addListener(text, "propertychange", onTextInput);
|
||||
|
||||
event.addListener(text, "copy", onCopy);
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -52,14 +52,14 @@ var Cursor = function(parentEl) {
|
|||
|
||||
(function() {
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
this.doc = doc;
|
||||
this.setSession = function(session) {
|
||||
this.session = session;
|
||||
};
|
||||
|
||||
this.setCursor = function(position, overwrite) {
|
||||
this.position = {
|
||||
row : position.row,
|
||||
column : this.doc.documentToScreenColumn(position.row, position.column)
|
||||
column : this.session.documentToScreenColumn(position.row, position.column)
|
||||
};
|
||||
if (overwrite) {
|
||||
dom.addCssClass(this.cursor, "ace_overwrite");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var Gutter = function(parentEl) {
|
||||
this.element = document.createElement("div");
|
||||
this.element.className = "ace_layer ace_gutter-layer";
|
||||
|
|
@ -74,8 +76,7 @@ var Gutter = function(parentEl) {
|
|||
"' style='height:", config.lineHeight, "px;'>", (i+1), "</div>");
|
||||
html.push("</div>");
|
||||
}
|
||||
|
||||
this.element.innerHTML = html.join("");
|
||||
this.element = dom.setInnerHtml(this.element, html.join(""));
|
||||
this.element.style.height = config.minHeight + "px";
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -38,6 +38,7 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var Range = require("ace/range").Range;
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var Marker = function(parentEl) {
|
||||
this.element = document.createElement("div");
|
||||
|
|
@ -50,8 +51,8 @@ var Marker = function(parentEl) {
|
|||
|
||||
(function() {
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
this.doc = doc;
|
||||
this.setSession = function(session) {
|
||||
this.session = session;
|
||||
};
|
||||
|
||||
this.addMarker = function(range, clazz, type) {
|
||||
|
|
@ -97,15 +98,15 @@ var Marker = function(parentEl) {
|
|||
this.drawSingleLineMarker(html, range, marker.clazz, config);
|
||||
}
|
||||
}
|
||||
this.element.innerHTML = html.join("");
|
||||
this.element = dom.setInnerHtml(this.element, html.join(""));
|
||||
};
|
||||
|
||||
this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
|
||||
|
||||
// selection start
|
||||
var row = range.start.row;
|
||||
var lineRange = new Range(row, range.start.column, row, this.doc.getLine(row).length);
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig);
|
||||
var lineRange = new Range(row, range.start.column, row, this.session.getLine(row).length);
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1);
|
||||
|
||||
// selection end
|
||||
var row = range.end.row;
|
||||
|
|
@ -115,13 +116,13 @@ var Marker = function(parentEl) {
|
|||
for (var row = range.start.row + 1; row < range.end.row; row++) {
|
||||
lineRange.start.row = row;
|
||||
lineRange.end.row = row;
|
||||
lineRange.end.column = this.doc.getLine(row).length;
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig);
|
||||
lineRange.end.column = this.session.getLine(row).length; // account for endofline characters
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1);
|
||||
}
|
||||
};
|
||||
|
||||
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig) {
|
||||
var range = range.toScreenRange(this.doc);
|
||||
var range = range.toScreenRange(this.session);
|
||||
|
||||
// from selection start to the end of the line
|
||||
var height = layerConfig.lineHeight;
|
||||
|
|
@ -162,11 +163,11 @@ var Marker = function(parentEl) {
|
|||
);
|
||||
};
|
||||
|
||||
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig) {
|
||||
var range = range.toScreenRange(this.doc);
|
||||
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength) {
|
||||
var range = range.toScreenRange(this.session);
|
||||
|
||||
var height = layerConfig.lineHeight;
|
||||
var width = Math.round((range.end.column - range.start.column) * layerConfig.characterWidth);
|
||||
var width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth);
|
||||
var top = (range.start.row - layerConfig.firstRow) * layerConfig.lineHeight;
|
||||
var left = Math.round(range.start.column * layerConfig.characterWidth);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -125,18 +125,22 @@ var Text = function(parentEl) {
|
|||
return size;
|
||||
};
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
this.doc = doc;
|
||||
this.setSession = function(session) {
|
||||
this.session = session;
|
||||
};
|
||||
|
||||
this.$showInvisibles = false;
|
||||
this.showInvisibles = false;
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
this.$showInvisibles = showInvisibles;
|
||||
if (this.showInvisibles == showInvisibles)
|
||||
return false;
|
||||
|
||||
this.showInvisibles = showInvisibles;
|
||||
return true;
|
||||
};
|
||||
|
||||
this.$computeTabString = function() {
|
||||
var tabSize = this.doc.getTabSize();
|
||||
if (this.$showInvisibles) {
|
||||
var tabSize = this.session.getTabSize();
|
||||
if (this.showInvisibles) {
|
||||
var halfTab = (tabSize) / 2;
|
||||
this.$tabString = "<span class='ace_invisible'>"
|
||||
+ new Array(Math.floor(halfTab)).join(" ")
|
||||
|
|
@ -156,23 +160,19 @@ var Text = function(parentEl) {
|
|||
var last = Math.min(lastRow, layerConfig.lastRow);
|
||||
|
||||
var lineElements = this.element.childNodes;
|
||||
var _self = this;
|
||||
this.tokenizer.getTokens(first, last, function(tokens) {
|
||||
for ( var i = first; i <= last; i++) {
|
||||
var lineElement = lineElements[i - layerConfig.firstRow];
|
||||
if (!lineElement)
|
||||
continue;
|
||||
var tokens = this.tokenizer.getTokens(first, last);
|
||||
for (var i=first; i<=last; i++) {
|
||||
var lineElement = lineElements[i - layerConfig.firstRow];
|
||||
if (!lineElement)
|
||||
continue;
|
||||
|
||||
var html = [];
|
||||
_self.$renderLine(html, i, tokens[i-first].tokens);
|
||||
lineElement.innerHTML = html.join("");
|
||||
}
|
||||
});
|
||||
var html = [];
|
||||
this.$renderLine(html, i, tokens[i-first].tokens);
|
||||
dom.setInnerHtml(lineElement, html.join(""));
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollLines = function(config) {
|
||||
var _self = this;
|
||||
|
||||
this.$computeTabString();
|
||||
var oldConfig = this.config;
|
||||
this.config = config;
|
||||
|
|
@ -193,49 +193,37 @@ var Text = function(parentEl) {
|
|||
for (var row=config.lastRow+1; row<=oldConfig.lastRow; row++)
|
||||
el.removeChild(el.lastChild);
|
||||
|
||||
appendTop(appendBottom);
|
||||
|
||||
function appendTop(callback) {
|
||||
if (config.firstRow < oldConfig.firstRow) {
|
||||
_self.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1, function(fragment) {
|
||||
if (el.firstChild)
|
||||
el.insertBefore(fragment, el.firstChild);
|
||||
else
|
||||
el.appendChild(fragment);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
if (config.firstRow < oldConfig.firstRow) {
|
||||
var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
|
||||
if (el.firstChild)
|
||||
el.insertBefore(fragment, el.firstChild);
|
||||
else
|
||||
callback();
|
||||
el.appendChild(fragment);
|
||||
}
|
||||
|
||||
function appendBottom() {
|
||||
if (config.lastRow > oldConfig.lastRow) {
|
||||
_self.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow, function(fragment) {
|
||||
el.appendChild(fragment);
|
||||
});
|
||||
}
|
||||
|
||||
if (config.lastRow > oldConfig.lastRow) {
|
||||
var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
|
||||
el.appendChild(fragment);
|
||||
}
|
||||
};
|
||||
|
||||
this.$renderLinesFragment = function(config, firstRow, lastRow, callback) {
|
||||
this.$renderLinesFragment = function(config, firstRow, lastRow) {
|
||||
var fragment = document.createDocumentFragment();
|
||||
var _self = this;
|
||||
this.tokenizer.getTokens(firstRow, lastRow, function(tokens) {
|
||||
for (var row=firstRow; row<=lastRow; row++) {
|
||||
var lineEl = document.createElement("div");
|
||||
lineEl.className = "ace_line";
|
||||
var style = lineEl.style;
|
||||
style.height = _self.$characterSize.height + "px";
|
||||
style.width = config.width + "px";
|
||||
var tokens = this.tokenizer.getTokens(firstRow, lastRow);
|
||||
for (var row=firstRow; row<=lastRow; row++) {
|
||||
var lineEl = document.createElement("div");
|
||||
lineEl.className = "ace_line";
|
||||
var style = lineEl.style;
|
||||
style.height = this.$characterSize.height + "px";
|
||||
style.width = config.width + "px";
|
||||
|
||||
var html = [];
|
||||
_self.$renderLine(html, row, tokens[row-firstRow].tokens);
|
||||
lineEl.innerHTML = html.join("");
|
||||
fragment.appendChild(lineEl);
|
||||
}
|
||||
callback(fragment);
|
||||
});
|
||||
var html = [];
|
||||
this.$renderLine(html, row, tokens[row-firstRow].tokens);
|
||||
// don't use setInnerHtml since we are working with an empty DIV
|
||||
lineEl.innerHTML = html.join("");
|
||||
fragment.appendChild(lineEl);
|
||||
}
|
||||
return fragment;
|
||||
};
|
||||
|
||||
this.update = function(config) {
|
||||
|
|
@ -243,16 +231,14 @@ var Text = function(parentEl) {
|
|||
this.config = config;
|
||||
|
||||
var html = [];
|
||||
var _self = this;
|
||||
this.tokenizer.getTokens(config.firstRow, config.lastRow, function(tokens) {
|
||||
for ( var i = config.firstRow; i <= config.lastRow; i++) {
|
||||
html.push("<div class='ace_line' style='height:" + _self.$characterSize.height + "px;", "width:",
|
||||
config.width, "px'>");
|
||||
_self.$renderLine(html, i, tokens[i-config.firstRow].tokens), html.push("</div>");
|
||||
}
|
||||
var tokens = this.tokenizer.getTokens(config.firstRow, config.lastRow);
|
||||
for (var i=config.firstRow; i<=config.lastRow; i++) {
|
||||
html.push("<div class='ace_line' style='height:" + this.$characterSize.height + "px;", "width:",
|
||||
config.width, "px'>");
|
||||
this.$renderLine(html, i, tokens[i-config.firstRow].tokens), html.push("</div>");
|
||||
}
|
||||
|
||||
_self.element.innerHTML = html.join("");
|
||||
});
|
||||
this.element = dom.setInnerHtml(this.element, html.join(""));
|
||||
};
|
||||
|
||||
this.$textToken = {
|
||||
|
|
@ -262,7 +248,7 @@ var Text = function(parentEl) {
|
|||
};
|
||||
|
||||
this.$renderLine = function(stringBuilder, row, tokens) {
|
||||
// if (this.$showInvisibles) {
|
||||
// if (this.showInvisibles) {
|
||||
// var self = this;
|
||||
// var spaceRe = /[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]+/g;
|
||||
// var spaceReplace = function(space) {
|
||||
|
|
@ -293,8 +279,8 @@ var Text = function(parentEl) {
|
|||
}
|
||||
};
|
||||
|
||||
if (this.$showInvisibles) {
|
||||
if (row !== this.doc.getLength() - 1) {
|
||||
if (this.showInvisibles) {
|
||||
if (row !== this.session.getLength() - 1) {
|
||||
stringBuilder.push("<span class='ace_invisible'>" + this.EOL_CHAR + "</span>");
|
||||
} else {
|
||||
stringBuilder.push("<span class='ace_invisible'>" + this.EOF_CHAR + "</span>");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -76,7 +76,7 @@ JavaScriptHighlightRules = function() {
|
|||
next : "comment"
|
||||
}, {
|
||||
token : "string.regexp",
|
||||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/][gimy]*\\s*(?=[).,;]|$)"
|
||||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -110,8 +110,6 @@ var XmlHighlightRules = function() {
|
|||
};
|
||||
};
|
||||
|
||||
/fd/g
|
||||
|
||||
oop.inherits(XmlHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.XmlHighlightRules = XmlHighlightRules;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -71,7 +71,7 @@ var RenderLoop = function(onRender) {
|
|||
if (!this.attached) {
|
||||
var _self = this;
|
||||
event.addListener(window, "message", function(e) {
|
||||
if (e.source == window && _self.callback && e.data == _self.messageName) {
|
||||
if (_self.callback && e.data == _self.messageName) {
|
||||
event.stopPropagation(e);
|
||||
_self.callback();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -67,14 +67,14 @@ Search.SELECTION = 2;
|
|||
return lang.copyObject(this.$options);
|
||||
};
|
||||
|
||||
this.find = function(doc) {
|
||||
this.find = function(session) {
|
||||
if (!this.$options.needle)
|
||||
return null;
|
||||
|
||||
if (this.$options.backwards) {
|
||||
var iterator = this.$backwardMatchIterator(doc);
|
||||
var iterator = this.$backwardMatchIterator(session);
|
||||
} else {
|
||||
iterator = this.$forwardMatchIterator(doc);
|
||||
iterator = this.$forwardMatchIterator(session);
|
||||
}
|
||||
|
||||
var firstRange = null;
|
||||
|
|
@ -86,14 +86,14 @@ Search.SELECTION = 2;
|
|||
return firstRange;
|
||||
};
|
||||
|
||||
this.findAll = function(doc) {
|
||||
this.findAll = function(session) {
|
||||
if (!this.$options.needle)
|
||||
return [];
|
||||
|
||||
if (this.$options.backwards) {
|
||||
var iterator = this.$backwardMatchIterator(doc);
|
||||
var iterator = this.$backwardMatchIterator(session);
|
||||
} else {
|
||||
iterator = this.$forwardMatchIterator(doc);
|
||||
iterator = this.$forwardMatchIterator(session);
|
||||
}
|
||||
|
||||
var ranges = [];
|
||||
|
|
@ -118,13 +118,13 @@ Search.SELECTION = 2;
|
|||
}
|
||||
};
|
||||
|
||||
this.$forwardMatchIterator = function(doc) {
|
||||
this.$forwardMatchIterator = function(session) {
|
||||
var re = this.$assembleRegExp();
|
||||
var self = this;
|
||||
|
||||
return {
|
||||
forEach: function(callback) {
|
||||
self.$forwardLineIterator(doc).forEach(function(line, startIndex, row) {
|
||||
self.$forwardLineIterator(session).forEach(function(line, startIndex, row) {
|
||||
if (startIndex) {
|
||||
line = line.substring(startIndex);
|
||||
}
|
||||
|
|
@ -152,13 +152,13 @@ Search.SELECTION = 2;
|
|||
};
|
||||
};
|
||||
|
||||
this.$backwardMatchIterator = function(doc) {
|
||||
this.$backwardMatchIterator = function(session) {
|
||||
var re = this.$assembleRegExp();
|
||||
var self = this;
|
||||
|
||||
return {
|
||||
forEach: function(callback) {
|
||||
self.$backwardLineIterator(doc).forEach(function(line, startIndex, row) {
|
||||
self.$backwardLineIterator(session).forEach(function(line, startIndex, row) {
|
||||
if (startIndex) {
|
||||
line = line.substring(startIndex);
|
||||
}
|
||||
|
|
@ -208,20 +208,20 @@ Search.SELECTION = 2;
|
|||
return re;
|
||||
};
|
||||
|
||||
this.$forwardLineIterator = function(doc) {
|
||||
this.$forwardLineIterator = function(session) {
|
||||
var searchSelection = this.$options.scope == Search.SELECTION;
|
||||
|
||||
var range = doc.getSelection().getRange();
|
||||
var start = doc.getSelection().getCursor();
|
||||
var range = session.getSelection().getRange();
|
||||
var start = session.getSelection().getCursor();
|
||||
|
||||
var firstRow = searchSelection ? range.start.row : 0;
|
||||
var firstColumn = searchSelection ? range.start.column : 0;
|
||||
var lastRow = searchSelection ? range.end.row : doc.getLength() - 1;
|
||||
var lastRow = searchSelection ? range.end.row : session.getLength() - 1;
|
||||
|
||||
var wrap = this.$options.wrap;
|
||||
|
||||
function getLine(row) {
|
||||
var line = doc.getLine(row);
|
||||
var line = session.getLine(row);
|
||||
if (searchSelection && row == range.end.row) {
|
||||
line = line.substring(0, range.end.column);
|
||||
}
|
||||
|
|
@ -264,15 +264,15 @@ Search.SELECTION = 2;
|
|||
};
|
||||
};
|
||||
|
||||
this.$backwardLineIterator = function(doc) {
|
||||
this.$backwardLineIterator = function(session) {
|
||||
var searchSelection = this.$options.scope == Search.SELECTION;
|
||||
|
||||
var range = doc.getSelection().getRange();
|
||||
var range = session.getSelection().getRange();
|
||||
var start = searchSelection ? range.end : range.start;
|
||||
|
||||
var firstRow = searchSelection ? range.start.row : 0;
|
||||
var firstColumn = searchSelection ? range.start.column : 0;
|
||||
var lastRow = searchSelection ? range.end.row : doc.getLength() - 1;
|
||||
var lastRow = searchSelection ? range.end.row : session.getLength() - 1;
|
||||
|
||||
var wrap = this.$options.wrap;
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ Search.SELECTION = 2;
|
|||
forEach : function(callback) {
|
||||
var row = start.row;
|
||||
|
||||
var line = doc.getLine(row).substring(0, start.column);
|
||||
var line = session.getLine(row).substring(0, start.column);
|
||||
var startIndex = 0;
|
||||
var stop = false;
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ Search.SELECTION = 2;
|
|||
if (row == start.row)
|
||||
stop = true;
|
||||
|
||||
line = doc.getLine(row);
|
||||
line = session.getLine(row);
|
||||
if (searchSelection) {
|
||||
if (row == firstRow)
|
||||
startIndex = firstColumn;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -150,9 +150,16 @@ var Selection = function(doc) {
|
|||
var lastRow = this.doc.getLength() - 1;
|
||||
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
|
||||
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(0, 0);
|
||||
});
|
||||
if (!this.selectionAnchor) {
|
||||
this.selectionAnchor = this.$clone(this.selectionLead);
|
||||
}
|
||||
|
||||
var cursor = {row:0, column:0};
|
||||
// only dispatch change if the cursor actually changed
|
||||
if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) {
|
||||
this.selectionLead = cursor;
|
||||
this._dispatchEvent("changeSelection", {blockScrolling: true});
|
||||
}
|
||||
};
|
||||
|
||||
this.setSelectionRange = function(range, reverse) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,11 +37,12 @@
|
|||
|
||||
require("../../../support/paths");
|
||||
|
||||
var async = require("async");
|
||||
var async = require("asyncjs");
|
||||
|
||||
async.concat(
|
||||
require("./change_document_test"),
|
||||
require("./document_test"),
|
||||
require("./edit_session_test"),
|
||||
require("./event_emitter_test"),
|
||||
require("./navigation_test"),
|
||||
require("./range_test"),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -49,11 +49,7 @@ assert.range = function(range, startRow, startColumn, endRow, endColumn) {
|
|||
assert.position(range.end, endRow, endColumn);
|
||||
};
|
||||
|
||||
assert.true = function(value) {
|
||||
assert.equal(value, true);
|
||||
}
|
||||
|
||||
assert.false = function(value) {
|
||||
assert.notOk = function(value) {
|
||||
assert.equal(value, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -39,7 +39,7 @@ define(function(require, exports, module) {
|
|||
|
||||
require("./mockdom");
|
||||
|
||||
var Document = require("../document").Document,
|
||||
var EditSession = require("../edit_session").EditSession,
|
||||
Editor = require("../editor").Editor,
|
||||
Text = require("../mode/text").Mode,
|
||||
JavaScriptMode = require("../mode/javascript").Mode,
|
||||
|
|
@ -47,18 +47,20 @@ var Document = require("../document").Document,
|
|||
assert = require("./assertions");
|
||||
|
||||
var Test = {
|
||||
setUp : function() {
|
||||
this.doc1 = new Document(["abc", "def"].join("\n"));
|
||||
this.doc2 = new Document(["ghi", "jkl"].join("\n"));
|
||||
|
||||
setUp : function(next) {
|
||||
this.session1 = new EditSession(["abc", "def"]);
|
||||
this.session2 = new EditSession(["ghi", "jkl"]);
|
||||
this.editor = new Editor(new MockRenderer());
|
||||
next();
|
||||
},
|
||||
|
||||
"test: change document" : function() {
|
||||
this.editor.setDocument(this.doc1);
|
||||
assert.equal(this.editor.getDocument(), this.doc1);
|
||||
this.editor.setSession(this.session1);
|
||||
assert.equal(this.editor.getSession(), this.session1);
|
||||
|
||||
this.editor.setDocument(this.doc2);
|
||||
assert.equal(this.editor.getDocument(), this.doc2);
|
||||
this.editor.setSession(this.session2);
|
||||
assert.equal(this.editor.getSession(), this.session2);
|
||||
},
|
||||
|
||||
"test: only changes to the new document should have effect" : function() {
|
||||
|
|
@ -67,24 +69,24 @@ var Test = {
|
|||
called = true;
|
||||
};
|
||||
|
||||
this.editor.setDocument(this.doc1);
|
||||
this.editor.setDocument(this.doc2);
|
||||
this.editor.setSession(this.session1);
|
||||
this.editor.setSession(this.session2);
|
||||
|
||||
this.doc1.duplicateLines(0, 0);
|
||||
assert.false(called);
|
||||
this.session1.duplicateLines(0, 0);
|
||||
assert.notOk(called);
|
||||
|
||||
this.doc2.duplicateLines(0, 0);
|
||||
assert.true(called);
|
||||
this.session2.duplicateLines(0, 0);
|
||||
assert.ok(called);
|
||||
},
|
||||
|
||||
"test: should use cursor of new document" : function() {
|
||||
this.doc1.getSelection().moveCursorTo(0, 1);
|
||||
this.doc2.getSelection().moveCursorTo(1, 0);
|
||||
this.session1.getSelection().moveCursorTo(0, 1);
|
||||
this.session2.getSelection().moveCursorTo(1, 0);
|
||||
|
||||
this.editor.setDocument(this.doc1);
|
||||
this.editor.setSession(this.session1);
|
||||
assert.position(this.editor.getCursorPosition(), 0, 1);
|
||||
|
||||
this.editor.setDocument(this.doc2);
|
||||
this.editor.setSession(this.session2);
|
||||
assert.position(this.editor.getCursorPosition(), 1, 0);
|
||||
},
|
||||
|
||||
|
|
@ -93,28 +95,28 @@ var Test = {
|
|||
called = true;
|
||||
};
|
||||
|
||||
this.editor.setDocument(this.doc1);
|
||||
this.editor.setDocument(this.doc2);
|
||||
this.editor.setSession(this.session1);
|
||||
this.editor.setSession(this.session2);
|
||||
assert.position(this.editor.getCursorPosition(), 0, 0);
|
||||
|
||||
var called = false;
|
||||
this.doc1.getSelection().moveCursorTo(0, 1);
|
||||
this.session1.getSelection().moveCursorTo(0, 1);
|
||||
assert.position(this.editor.getCursorPosition(), 0, 0);
|
||||
assert.false(called);
|
||||
assert.notOk(called);
|
||||
|
||||
this.doc2.getSelection().moveCursorTo(1, 1);
|
||||
this.session2.getSelection().moveCursorTo(1, 1);
|
||||
assert.position(this.editor.getCursorPosition(), 1, 1);
|
||||
assert.true(called);
|
||||
assert.ok(called);
|
||||
},
|
||||
|
||||
"test: should use selection of new document" : function() {
|
||||
this.doc1.getSelection().selectTo(0, 1);
|
||||
this.doc2.getSelection().selectTo(1, 0);
|
||||
this.session1.getSelection().selectTo(0, 1);
|
||||
this.session2.getSelection().selectTo(1, 0);
|
||||
|
||||
this.editor.setDocument(this.doc1);
|
||||
this.editor.setSession(this.session1);
|
||||
assert.position(this.editor.getSelection().getSelectionLead(), 0, 1);
|
||||
|
||||
this.editor.setDocument(this.doc2);
|
||||
this.editor.setSession(this.session2);
|
||||
assert.position(this.editor.getSelection().getSelectionLead(), 1, 0);
|
||||
},
|
||||
|
||||
|
|
@ -123,37 +125,37 @@ var Test = {
|
|||
called = true;
|
||||
};
|
||||
|
||||
this.editor.setDocument(this.doc1);
|
||||
this.editor.setDocument(this.doc2);
|
||||
this.editor.setSession(this.session1);
|
||||
this.editor.setSession(this.session2);
|
||||
assert.position(this.editor.getSelection().getSelectionLead(), 0, 0);
|
||||
|
||||
var called = false;
|
||||
this.doc1.getSelection().selectTo(0, 1);
|
||||
this.session1.getSelection().selectTo(0, 1);
|
||||
assert.position(this.editor.getSelection().getSelectionLead(), 0, 0);
|
||||
assert.false(called);
|
||||
assert.notOk(called);
|
||||
|
||||
this.doc2.getSelection().selectTo(1, 1);
|
||||
this.session2.getSelection().selectTo(1, 1);
|
||||
assert.position(this.editor.getSelection().getSelectionLead(), 1, 1);
|
||||
assert.true(called);
|
||||
assert.ok(called);
|
||||
},
|
||||
|
||||
"test: should use mode of new document" : function() {
|
||||
this.editor.onDocumentModeChange = function() {
|
||||
called = true;
|
||||
};
|
||||
this.editor.setDocument(this.doc1);
|
||||
this.editor.setDocument(this.doc2);
|
||||
this.editor.setSession(this.session1);
|
||||
this.editor.setSession(this.session2);
|
||||
|
||||
var called = false;
|
||||
this.doc1.setMode(new Text());
|
||||
assert.false(called);
|
||||
this.session1.setMode(new Text());
|
||||
assert.notOk(called);
|
||||
|
||||
this.doc2.setMode(new JavaScriptMode());
|
||||
assert.true(called);
|
||||
this.session2.setMode(new JavaScriptMode());
|
||||
assert.ok(called);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -35,193 +35,252 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("../document").Document,
|
||||
UndoManager = require("../undomanager").UndoManager,
|
||||
MockRenderer = require("./mockrenderer"),
|
||||
Range = require("../range").Range,
|
||||
assert = require("./assertions"),
|
||||
async = require("async");
|
||||
async = require("asyncjs");
|
||||
|
||||
var Test = {
|
||||
|
||||
"test: find matching opening bracket" : function() {
|
||||
var doc = new Document(["(()(", "())))"]);
|
||||
"test: insert text in line" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
assert.position(doc.findMatchingBracket({row: 0, column: 3}), 0, 1);
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 2}), 1, 0);
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 3}), 0, 3);
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 4}), 0, 0);
|
||||
assert.equal(doc.findMatchingBracket({row: 1, column: 5}), null);
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insert({row: 0, column: 1}, "juhu");
|
||||
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert new line" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertNewLine({row: 0, column: 1});
|
||||
assert.equal(doc.getValue(), ["1", "2", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1", "2", "34"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert lines at the beginning" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertLines(0, ["aa", "bb"]);
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert lines at the end" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertLines(2, ["aa", "bb"]);
|
||||
assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert lines in the middle" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertLines(1, ["aa", "bb"]);
|
||||
assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert multi line string at the start" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
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"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert multi line string at the end" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insert({row: 2, column: 0}, "aa\nbb\ncc");
|
||||
assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert multi line string in the middle" : function() {
|
||||
var doc = new Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
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"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n"));
|
||||
},
|
||||
|
||||
"test: delete in line" : function() {
|
||||
var doc = new Document(["1234", "5678"]);
|
||||
|
||||
var deltas = [];
|
||||
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"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1234", "5678"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["14", "5678"].join("\n"));
|
||||
},
|
||||
|
||||
"test: find matching closing bracket" : function() {
|
||||
var doc = new Document(["(()(", "())))"]);
|
||||
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 1}), 1, 1);
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 1}), 1, 1);
|
||||
assert.position(doc.findMatchingBracket({row: 0, column: 4}), 1, 2);
|
||||
assert.position(doc.findMatchingBracket({row: 0, column: 2}), 0, 2);
|
||||
assert.position(doc.findMatchingBracket({row: 0, column: 1}), 1, 3);
|
||||
assert.equal(doc.findMatchingBracket({row: 0, column: 0}), null);
|
||||
"test: delete new line" : function() {
|
||||
var doc = new Document(["1234", "5678"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.remove(new Range(0, 4, 1, 0));
|
||||
assert.equal(doc.getValue(), ["12345678"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1234", "5678"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12345678"].join("\n"));
|
||||
},
|
||||
|
||||
"test: match different bracket types" : function() {
|
||||
var doc = new Document(["({[", ")]}"]);
|
||||
|
||||
assert.position(doc.findMatchingBracket({row: 0, column: 1}), 1, 0);
|
||||
assert.position(doc.findMatchingBracket({row: 0, column: 2}), 1, 2);
|
||||
assert.position(doc.findMatchingBracket({row: 0, column: 3}), 1, 1);
|
||||
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 1}), 0, 0);
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 2}), 0, 2);
|
||||
assert.position(doc.findMatchingBracket({row: 1, column: 3}), 0, 1);
|
||||
|
||||
"test: delete multi line range line" : function() {
|
||||
var doc = new Document(["1234", "5678", "abcd"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.remove(new Range(0, 2, 2, 2));
|
||||
assert.equal(doc.getValue(), ["12cd"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1234", "5678", "abcd"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12cd"].join("\n"));
|
||||
},
|
||||
|
||||
"test: move lines down" : function() {
|
||||
var doc = new Document(["a1", "a2", "a3", "a4"]);
|
||||
|
||||
"test: delete full lines" : function() {
|
||||
var doc = new Document(["1234", "5678", "abcd"]);
|
||||
|
||||
doc.moveLinesDown(0, 1);
|
||||
assert.equal(doc.toString(), ["a3", "a1", "a2", "a4"].join("\n"));
|
||||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.moveLinesDown(1, 2);
|
||||
assert.equal(doc.toString(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
doc.moveLinesDown(2, 3);
|
||||
assert.equal(doc.toString(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
doc.moveLinesDown(2, 2);
|
||||
assert.equal(doc.toString(), ["a3", "a4", "a2", "a1"].join("\n"));
|
||||
doc.remove(new Range(1, 0, 3, 0));
|
||||
assert.equal(doc.getValue(), ["1234", ""].join("\n"));
|
||||
},
|
||||
|
||||
"test: move lines up" : function() {
|
||||
var doc = new Document(["a1", "a2", "a3", "a4"]);
|
||||
|
||||
doc.moveLinesUp(2, 3);
|
||||
assert.equal(doc.toString(), ["a1", "a3", "a4", "a2"].join("\n"));
|
||||
|
||||
"test: remove lines should return the removed lines" : function() {
|
||||
var doc = new Document(["1234", "5678", "abcd"]);
|
||||
|
||||
doc.moveLinesUp(1, 2);
|
||||
assert.equal(doc.toString(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
doc.moveLinesUp(0, 1);
|
||||
assert.equal(doc.toString(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
doc.moveLinesUp(2, 2);
|
||||
assert.equal(doc.toString(), ["a3", "a1", "a4", "a2"].join("\n"));
|
||||
},
|
||||
|
||||
"test: duplicate lines" : function() {
|
||||
var doc = new Document(["1", "2", "3", "4"]);
|
||||
|
||||
doc.duplicateLines(1, 2);
|
||||
assert.equal(doc.toString(), ["1", "2", "3", "2", "3", "4"].join("\n"));
|
||||
},
|
||||
|
||||
"test: duplicate last line" : function() {
|
||||
var doc = new Document(["1", "2", "3"]);
|
||||
|
||||
doc.duplicateLines(2, 2);
|
||||
assert.equal(doc.toString(), ["1", "2", "3", "3"].join("\n"));
|
||||
},
|
||||
|
||||
"test: duplicate first line" : function() {
|
||||
var doc = new Document(["1", "2", "3"]);
|
||||
|
||||
doc.duplicateLines(0, 0);
|
||||
assert.equal(doc.toString(), ["1", "1", "2", "3"].join("\n"));
|
||||
var removed = doc.removeLines(1, 2);
|
||||
assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n"));
|
||||
},
|
||||
|
||||
"test: should handle unix style new lines" : function() {
|
||||
var doc = new Document(["1", "2", "3"]);
|
||||
|
||||
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
},
|
||||
|
||||
"test: should handle windows style new lines" : function() {
|
||||
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.setNewLineMode("unix");
|
||||
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
},
|
||||
|
||||
"test: set new line mode to 'windows' should use '\r\n' as new lines": function() {
|
||||
var doc = new Document(["1", "2", "3"].join("\n"));
|
||||
doc.setNewLineMode("windows");
|
||||
assert.equal(doc.toString(), ["1", "2", "3"].join("\r\n"));
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n"));
|
||||
},
|
||||
|
||||
"test: set new line mode to 'unix' should use '\n' as new lines": function() {
|
||||
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.setNewLineMode("unix");
|
||||
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
},
|
||||
|
||||
"test: set new line mode to 'auto' should detect the incoming nl type": function() {
|
||||
var doc = new Document(["1", "2", "3"].join("\n"));
|
||||
|
||||
doc.setNewLineMode("auto");
|
||||
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
|
||||
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.setNewLineMode("auto");
|
||||
assert.equal(doc.toString(), ["1", "2", "3"].join("\r\n"));
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.replace(new Range(0, 0, 2, 1), ["4", "5", "6"].join("\n"));
|
||||
assert.equal(["4", "5", "6"].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
"test: convert document to screen coordinates" : function() {
|
||||
var doc = new Document("01234\t567890\t1234");
|
||||
doc.setTabSize(4);
|
||||
|
||||
assert.equal(doc.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(doc.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(doc.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(doc.documentToScreenColumn(0, 6), 9);
|
||||
assert.equal(doc.documentToScreenColumn(0, 12), 15);
|
||||
assert.equal(doc.documentToScreenColumn(0, 13), 19);
|
||||
|
||||
doc.setTabSize(2);
|
||||
|
||||
assert.equal(doc.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(doc.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(doc.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(doc.documentToScreenColumn(0, 6), 7);
|
||||
assert.equal(doc.documentToScreenColumn(0, 12), 13);
|
||||
assert.equal(doc.documentToScreenColumn(0, 13), 15);
|
||||
},
|
||||
|
||||
"test: convert document to scrren coordinates with leading tabs": function() {
|
||||
var doc = new Document("\t\t123");
|
||||
doc.setTabSize(4);
|
||||
|
||||
assert.equal(doc.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(doc.documentToScreenColumn(0, 1), 4);
|
||||
assert.equal(doc.documentToScreenColumn(0, 2), 8);
|
||||
assert.equal(doc.documentToScreenColumn(0, 3), 9);
|
||||
},
|
||||
|
||||
"test: convert screen to document coordinates" : function() {
|
||||
var doc = new Document("01234\t567890\t1234");
|
||||
doc.setTabSize(4);
|
||||
|
||||
assert.equal(doc.screenToDocumentColumn(0, 0), 0);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 4), 4);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 5), 5);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 6), 5);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 7), 5);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 8), 5);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 9), 6);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 15), 12);
|
||||
assert.equal(doc.screenToDocumentColumn(0, 19), 13);
|
||||
assert.equal(["4", "5", "6"].join("\n"), doc.getValue());
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
});
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
|
||||
if (module === require.main) {
|
||||
require("../../../support/paths");
|
||||
|
|
|
|||
275
lib/ace/test/edit_session_test.js
Normal file
275
lib/ace/test/edit_session_test.js
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var EditSession = require("ace/edit_session").EditSession,
|
||||
UndoManager = require("ace/undomanager").UndoManager,
|
||||
MockRenderer = require("./mockrenderer"),
|
||||
Range = require("ace/range").Range,
|
||||
assert = require("./assertions"),
|
||||
async = require("asyncjs");
|
||||
|
||||
var Test = {
|
||||
|
||||
"test: find matching opening bracket" : function() {
|
||||
var session = new EditSession(["(()(", "())))"]);
|
||||
|
||||
assert.position(session.findMatchingBracket({row: 0, column: 3}), 0, 1);
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 2}), 1, 0);
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 3}), 0, 3);
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 4}), 0, 0);
|
||||
assert.equal(session.findMatchingBracket({row: 1, column: 5}), null);
|
||||
},
|
||||
|
||||
"test: find matching closing bracket" : function() {
|
||||
var session = new EditSession(["(()(", "())))"]);
|
||||
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 1}), 1, 1);
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 1}), 1, 1);
|
||||
assert.position(session.findMatchingBracket({row: 0, column: 4}), 1, 2);
|
||||
assert.position(session.findMatchingBracket({row: 0, column: 2}), 0, 2);
|
||||
assert.position(session.findMatchingBracket({row: 0, column: 1}), 1, 3);
|
||||
assert.equal(session.findMatchingBracket({row: 0, column: 0}), null);
|
||||
},
|
||||
|
||||
"test: match different bracket types" : function() {
|
||||
var session = new EditSession(["({[", ")]}"]);
|
||||
|
||||
assert.position(session.findMatchingBracket({row: 0, column: 1}), 1, 0);
|
||||
assert.position(session.findMatchingBracket({row: 0, column: 2}), 1, 2);
|
||||
assert.position(session.findMatchingBracket({row: 0, column: 3}), 1, 1);
|
||||
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 1}), 0, 0);
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 2}), 0, 2);
|
||||
assert.position(session.findMatchingBracket({row: 1, column: 3}), 0, 1);
|
||||
},
|
||||
|
||||
"test: move lines down" : function() {
|
||||
var session = new EditSession(["a1", "a2", "a3", "a4"]);
|
||||
|
||||
session.moveLinesDown(0, 1);
|
||||
assert.equal(session.getValue(), ["a3", "a1", "a2", "a4"].join("\n"));
|
||||
|
||||
session.moveLinesDown(1, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesDown(2, 3);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesDown(2, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a2", "a1"].join("\n"));
|
||||
},
|
||||
|
||||
"test: move lines up" : function() {
|
||||
var session = new EditSession(["a1", "a2", "a3", "a4"]);
|
||||
|
||||
session.moveLinesUp(2, 3);
|
||||
assert.equal(session.getValue(), ["a1", "a3", "a4", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesUp(1, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesUp(0, 1);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesUp(2, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a1", "a4", "a2"].join("\n"));
|
||||
},
|
||||
|
||||
"test: duplicate lines" : function() {
|
||||
var session = new EditSession(["1", "2", "3", "4"]);
|
||||
|
||||
session.duplicateLines(1, 2);
|
||||
assert.equal(session.getValue(), ["1", "2", "3", "2", "3", "4"].join("\n"));
|
||||
},
|
||||
|
||||
"test: duplicate last line" : function() {
|
||||
var session = new EditSession(["1", "2", "3"]);
|
||||
|
||||
session.duplicateLines(2, 2);
|
||||
assert.equal(session.getValue(), ["1", "2", "3", "3"].join("\n"));
|
||||
},
|
||||
|
||||
"test: duplicate first line" : function() {
|
||||
var session = new EditSession(["1", "2", "3"]);
|
||||
|
||||
session.duplicateLines(0, 0);
|
||||
assert.equal(session.getValue(), ["1", "1", "2", "3"].join("\n"));
|
||||
},
|
||||
|
||||
"test: convert document to screen coordinates" : function() {
|
||||
var session = new EditSession("01234\t567890\t1234");
|
||||
session.setTabSize(4);
|
||||
|
||||
assert.equal(session.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(session.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(session.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(session.documentToScreenColumn(0, 6), 9);
|
||||
assert.equal(session.documentToScreenColumn(0, 12), 15);
|
||||
assert.equal(session.documentToScreenColumn(0, 13), 19);
|
||||
|
||||
session.setTabSize(2);
|
||||
|
||||
assert.equal(session.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(session.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(session.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(session.documentToScreenColumn(0, 6), 7);
|
||||
assert.equal(session.documentToScreenColumn(0, 12), 13);
|
||||
assert.equal(session.documentToScreenColumn(0, 13), 15);
|
||||
},
|
||||
|
||||
"test: convert document to scrren coordinates with leading tabs": function() {
|
||||
var session = new EditSession("\t\t123");
|
||||
session.setTabSize(4);
|
||||
|
||||
assert.equal(session.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(session.documentToScreenColumn(0, 1), 4);
|
||||
assert.equal(session.documentToScreenColumn(0, 2), 8);
|
||||
assert.equal(session.documentToScreenColumn(0, 3), 9);
|
||||
},
|
||||
|
||||
"test: convert screen to document coordinates" : function() {
|
||||
var session = new EditSession("01234\t567890\t1234");
|
||||
session.setTabSize(4);
|
||||
|
||||
assert.equal(session.screenToDocumentColumn(0, 0), 0);
|
||||
assert.equal(session.screenToDocumentColumn(0, 4), 4);
|
||||
assert.equal(session.screenToDocumentColumn(0, 5), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 6), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 7), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 8), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 9), 6);
|
||||
assert.equal(session.screenToDocumentColumn(0, 15), 12);
|
||||
assert.equal(session.screenToDocumentColumn(0, 19), 13);
|
||||
},
|
||||
|
||||
"test: insert text in multiple rows": function() {
|
||||
var session = new EditSession(["12", "", "abcd"]);
|
||||
|
||||
var inserted = session.multiRowInsert([0, 1, 2], 2, "juhu 1");
|
||||
assert.equal(inserted.rows, 0);
|
||||
assert.equal(inserted.columns, 6);
|
||||
|
||||
assert.equal(session.getValue(), ["12juhu 1", " juhu 1", "abjuhu 1cd"].join("\n"));
|
||||
},
|
||||
|
||||
"test: undo insert text in multiple rows": function() {
|
||||
var session = new EditSession(["12", "", "abcd"]);
|
||||
|
||||
var undoManager = new UndoManager();
|
||||
session.setUndoManager(undoManager);
|
||||
|
||||
session.multiRowInsert([0, 1, 2], 2, "juhu 1");
|
||||
session.$informUndoManager.call();
|
||||
assert.equal(session.getValue(), ["12juhu 1", " juhu 1", "abjuhu 1cd"].join("\n"));
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.getValue(), ["12", "", "abcd"].join("\n"));
|
||||
|
||||
undoManager.redo();
|
||||
assert.equal(session.getValue(), ["12juhu 1", " juhu 1", "abjuhu 1cd"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert new line in multiple rows": function() {
|
||||
var session = new EditSession(["12", "", "abcd"]);
|
||||
|
||||
var inserted = session.multiRowInsert([0, 1, 2], 2, "\n");
|
||||
assert.equal(inserted.rows, 1);
|
||||
assert.equal(session.getValue(), ["12\n", " \n", "ab\ncd"].join("\n"));
|
||||
},
|
||||
|
||||
"test: insert multi line text in multiple rows": function() {
|
||||
var session = new EditSession(["12", "", "abcd"]);
|
||||
|
||||
var inserted = session.multiRowInsert([0, 1, 2], 2, "juhu\n12");
|
||||
assert.equal(inserted.rows, 1);
|
||||
assert.equal(session.getValue(), ["12juhu\n12", " juhu\n12", "abjuhu\n12cd"].join("\n"));
|
||||
},
|
||||
|
||||
"test: remove right in multiple rows" : function() {
|
||||
var session = new EditSession(["12", "", "abcd"]);
|
||||
|
||||
session.multiRowRemove([0, 1, 2], new Range(0, 2, 0, 3));
|
||||
assert.equal(session.getValue(), ["12", "", "abd"].join("\n"));
|
||||
},
|
||||
|
||||
"test: undo remove right in multiple rows" : function() {
|
||||
var session = new EditSession(["12", "", "abcd"]);
|
||||
var undoManager = new UndoManager();
|
||||
session.setUndoManager(undoManager);
|
||||
|
||||
session.multiRowRemove([0, 1, 2], new Range(0, 1, 0, 3));
|
||||
session.$informUndoManager.call();
|
||||
assert.equal(session.getValue(), ["1", "", "ad"].join("\n"));
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.getValue(), ["12", "", "abcd"].join("\n"));
|
||||
|
||||
undoManager.redo();
|
||||
assert.equal(session.getValue(), ["1", "", "ad"].join("\n"));
|
||||
},
|
||||
|
||||
"test get longest line" : function() {
|
||||
var session = new EditSession(["12"]);
|
||||
session.setTabSize(4);
|
||||
assert.equal(session.getWidth(), 2);
|
||||
assert.equal(session.getScreenWidth(), 2);
|
||||
|
||||
session.doc.insertNewLine(0);
|
||||
session.doc.insertLines(1, ["123"]);
|
||||
assert.equal(session.getWidth(), 3);
|
||||
assert.equal(session.getScreenWidth(), 3);
|
||||
|
||||
session.doc.insertNewLine(0);
|
||||
session.doc.insertLines(1, ["\t\t"]);
|
||||
assert.equal(session.getWidth(), 3);
|
||||
assert.equal(session.getScreenWidth(), 8);
|
||||
|
||||
session.setTabSize(2);
|
||||
assert.equal(session.getWidth(), 3);
|
||||
assert.equal(session.getScreenWidth(), 4);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
require("../../../support/paths");
|
||||
exports.exec()
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -56,11 +56,11 @@ var Test = {
|
|||
});
|
||||
|
||||
emitter._dispatchEvent("juhu");
|
||||
assert.true(called);
|
||||
assert.ok(called);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test)
|
||||
module.exports = require("asyncjs/test").testcase(Test)
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -69,8 +69,12 @@ MockRenderer.prototype.getMouseEventTarget = function() {
|
|||
return this.container;
|
||||
};
|
||||
|
||||
MockRenderer.prototype.setDocument = function(doc) {
|
||||
this.lines = doc.lines;
|
||||
MockRenderer.prototype.setSession = function(session) {
|
||||
this.session = session;
|
||||
};
|
||||
|
||||
MockRenderer.prototype.getSession = function(session) {
|
||||
return this.session;
|
||||
};
|
||||
|
||||
MockRenderer.prototype.setTokenizer = function() {
|
||||
|
|
@ -91,7 +95,7 @@ MockRenderer.prototype.scrollCursorIntoView = function() {
|
|||
};
|
||||
|
||||
MockRenderer.prototype.scrollToRow = function(row) {
|
||||
var row = Math.min(this.lines.length - this.visibleRowCount, Math.max(0,
|
||||
var row = Math.min(this.session.getLength() - this.visibleRowCount, Math.max(0,
|
||||
row));
|
||||
this.layerConfig.firstVisibleRow = row;
|
||||
this.layerConfig.lastVisibleRow = row + this.visibleRowCount;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var CssMode = require("ace/mode/css").Mode;
|
||||
var assert = require("../assertions");
|
||||
|
||||
|
|
@ -47,10 +47,10 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: toggle comment lines should not do anything" : function() {
|
||||
var doc = new Document([" abc", "cde", "fg"].join("\n"));
|
||||
var session = new EditSession([" abc", "cde", "fg"].join("\n"));
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -84,7 +84,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test, "css tokenizer");
|
||||
module.exports = require("asyncjs/test").testcase(Test, "css tokenizer");
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var Range = require("ace/range").Range;
|
||||
var HtmlMode = require("ace/mode/html").Mode;
|
||||
var assert = require("../assertions");
|
||||
|
|
@ -48,11 +48,11 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: toggle comment lines should not do anything" : function() {
|
||||
var doc = new Document([" abc", "cde", "fg"]);
|
||||
var session = new EditSession([" abc", "cde", "fg"]);
|
||||
|
||||
var range = new Range(0, 3, 1, 1);
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: next line indent should be the same as the current line indent" : function() {
|
||||
|
|
@ -62,7 +62,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -65,7 +65,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
var assert = require("../assertions");
|
||||
|
|
@ -57,39 +57,39 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: toggle comment lines should prepend '//' to each line" : function() {
|
||||
var doc = new Document([" abc", "cde", "fg"]);
|
||||
var session = new EditSession([" abc", "cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 1);
|
||||
assert.equal(["// abc", "//cde", "fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal(["// abc", "//cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: toggle comment on commented lines should remove leading '//' chars" : function() {
|
||||
var doc = new Document(["// abc", "//cde", "fg"]);
|
||||
var session = new EditSession(["// abc", "//cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: toggle comment lines twice should return the original text" : function() {
|
||||
var doc = new Document([" abc", "cde", "fg"]);
|
||||
var session = new EditSession([" abc", "cde", "fg"]);
|
||||
|
||||
this.mode.toggleCommentLines("start", doc, 0, 2);
|
||||
this.mode.toggleCommentLines("start", doc, 0, 2);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
this.mode.toggleCommentLines("start", session, 0, 2);
|
||||
this.mode.toggleCommentLines("start", session, 0, 2);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: toggle comment on multiple lines with one commented line prepend '//' to each line" : function() {
|
||||
var doc = new Document(["// abc", "//cde", "fg"]);
|
||||
var session = new EditSession(["// abc", "//cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 2);
|
||||
assert.equal(["//// abc", "////cde", "//fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 2);
|
||||
assert.equal(["//// abc", "////cde", "//fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: toggle comment on a comment line with leading white space": function() {
|
||||
var doc = new Document(["//cde", " //fg"]);
|
||||
var session = new EditSession(["//cde", " //fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 1);
|
||||
assert.equal(["cde", " fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal(["cde", " fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: auto indent after opening brace" : function() {
|
||||
|
|
@ -132,19 +132,19 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: auto outdent should indent the line with the same indent as the line with the matching opening brace" : function() {
|
||||
var doc = new Document([" function foo() {", " bla", " }"]);
|
||||
this.mode.autoOutdent("start", doc, 2);
|
||||
assert.equal(" }", doc.getLine(2));
|
||||
var session = new EditSession([" function foo() {", " bla", " }"]);
|
||||
this.mode.autoOutdent("start", session, 2);
|
||||
assert.equal(" }", session.getLine(2));
|
||||
},
|
||||
|
||||
"test: no auto outdent if no matching brace is found" : function() {
|
||||
var doc = new Document([" function foo()", " bla", " }"]);
|
||||
this.mode.autoOutdent("start", doc, 2);
|
||||
assert.equal(" }", doc.getLine(2));
|
||||
var session = new EditSession([" function foo()", " bla", " }"]);
|
||||
this.mode.autoOutdent("start", session, 2);
|
||||
assert.equal(" }", session.getLine(2));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -101,7 +101,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var assert = require("../assertions");
|
||||
|
||||
|
|
@ -47,10 +47,10 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: toggle comment lines should not do anything" : function() {
|
||||
var doc = new Document([" abc", "cde", "fg"]);
|
||||
var session = new EditSession([" abc", "cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var XmlMode = require("ace/mode/xml").Mode;
|
||||
var assert = require("../assertions");
|
||||
|
|
@ -57,10 +57,10 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: toggle comment lines should not do anything" : function() {
|
||||
var doc = new Document([" abc", "cde", "fg"]);
|
||||
var session = new EditSession([" abc", "cde", "fg"]);
|
||||
|
||||
var comment = this.mode.toggleCommentLines("start", doc, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: next line indent should be the same as the current line indent" : function() {
|
||||
|
|
@ -70,7 +70,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -60,7 +60,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -39,31 +39,31 @@ define(function(require, exports, module) {
|
|||
|
||||
require("./mockdom");
|
||||
|
||||
var Document = require("../Document").Document,
|
||||
var EditSession = require("ace/edit_session").EditSession,
|
||||
Editor = require("../Editor").Editor,
|
||||
MockRenderer = require("./mockrenderer"),
|
||||
assert = require("./assertions");
|
||||
|
||||
var Test = {
|
||||
createTextDocument : function(rows, cols) {
|
||||
createEditSession : function(rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
return new Document(text);
|
||||
return new EditSession(text);
|
||||
},
|
||||
|
||||
"test: navigate to end of file should scroll the last line into view" : function() {
|
||||
var doc = this.createTextDocument(200, 10);
|
||||
var doc = this.createEditSession(200, 10);
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
|
||||
editor.navigateFileEnd();
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
||||
assert.true(editor.getFirstVisibleRow() <= cursor.row);
|
||||
assert.true(editor.getLastVisibleRow() >= cursor.row);
|
||||
assert.ok(editor.getFirstVisibleRow() <= cursor.row);
|
||||
assert.ok(editor.getLastVisibleRow() >= cursor.row);
|
||||
},
|
||||
|
||||
"test: navigate to start of file should scroll the first row into view" : function() {
|
||||
var doc = this.createTextDocument(200, 10);
|
||||
var doc = this.createEditSession(200, 10);
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
|
||||
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
|
||||
|
|
@ -73,7 +73,7 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: goto hidden line should scroll the line into the middle of the viewport" : function() {
|
||||
var editor = new Editor(new MockRenderer(), this.createTextDocument(200, 5));
|
||||
var editor = new Editor(new MockRenderer(), this.createEditSession(200, 5));
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(101);
|
||||
|
|
@ -107,7 +107,7 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: goto visible line should only move the cursor and not scroll": function() {
|
||||
var editor = new Editor(new MockRenderer(), this.createTextDocument(200, 5));
|
||||
var editor = new Editor(new MockRenderer(), this.createEditSession(200, 5));
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(12);
|
||||
|
|
@ -121,7 +121,7 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function() {
|
||||
var editor = new Editor(new MockRenderer(), new Document(["123456", "1"]));
|
||||
var editor = new Editor(new MockRenderer(), new EditSession(["123456", "1"]));
|
||||
|
||||
editor.navigateTo(0, 6);
|
||||
assert.position(editor.getCursorPosition(), 0, 6);
|
||||
|
|
@ -134,7 +134,7 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: reset desired column on navigate left or right": function() {
|
||||
var editor = new Editor(new MockRenderer(), new Document(["123456", "12"]));
|
||||
var editor = new Editor(new MockRenderer(), new EditSession(["123456", "12"]));
|
||||
|
||||
editor.navigateTo(0, 6);
|
||||
assert.position(editor.getCursorPosition(), 0, 6);
|
||||
|
|
@ -150,7 +150,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test)
|
||||
module.exports = require("asyncjs/test").testcase(Test)
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -66,24 +66,24 @@ var Test = {
|
|||
var range = new Range(0, 20, 3, 10);
|
||||
var range = range.clipRows(10, 30);
|
||||
|
||||
assert.true(range.isEmpty());
|
||||
assert.ok(range.isEmpty());
|
||||
assert.range(range, 10, 0, 10, 0);
|
||||
},
|
||||
|
||||
"test: isEmpty": function() {
|
||||
var range = new Range(1, 2, 1, 2);
|
||||
assert.true(range.isEmpty());
|
||||
assert.ok(range.isEmpty());
|
||||
|
||||
var range = new Range(1, 2, 1, 6);
|
||||
assert.false(range.isEmpty());
|
||||
assert.notOk(range.isEmpty());
|
||||
},
|
||||
|
||||
"test: is multi line": function() {
|
||||
var range = new Range(1, 2, 1, 6);
|
||||
assert.false(range.isMultiLine());
|
||||
assert.notOk(range.isMultiLine());
|
||||
|
||||
var range = new Range(1, 2, 2, 6);
|
||||
assert.true(range.isMultiLine());
|
||||
assert.ok(range.isMultiLine());
|
||||
},
|
||||
|
||||
"test: clone": function() {
|
||||
|
|
@ -103,28 +103,28 @@ var Test = {
|
|||
"test: contains for multi line ranges": function() {
|
||||
var range = new Range(1, 10, 5, 20);
|
||||
|
||||
assert.true(range.contains(1, 10));
|
||||
assert.true(range.contains(2, 0));
|
||||
assert.true(range.contains(3, 100));
|
||||
assert.true(range.contains(5, 19));
|
||||
assert.true(range.contains(5, 20));
|
||||
assert.ok(range.contains(1, 10));
|
||||
assert.ok(range.contains(2, 0));
|
||||
assert.ok(range.contains(3, 100));
|
||||
assert.ok(range.contains(5, 19));
|
||||
assert.ok(range.contains(5, 20));
|
||||
|
||||
assert.false(range.contains(1, 9));
|
||||
assert.false(range.contains(0, 0));
|
||||
assert.false(range.contains(5, 21));
|
||||
assert.notOk(range.contains(1, 9));
|
||||
assert.notOk(range.contains(0, 0));
|
||||
assert.notOk(range.contains(5, 21));
|
||||
},
|
||||
|
||||
"test: contains for single line ranges": function() {
|
||||
var range = new Range(1, 10, 1, 20);
|
||||
|
||||
assert.true(range.contains(1, 10));
|
||||
assert.true(range.contains(1, 15));
|
||||
assert.true(range.contains(1, 20));
|
||||
assert.ok(range.contains(1, 10));
|
||||
assert.ok(range.contains(1, 15));
|
||||
assert.ok(range.contains(1, 20));
|
||||
|
||||
assert.false(range.contains(0, 9));
|
||||
assert.false(range.contains(2, 9));
|
||||
assert.false(range.contains(1, 9));
|
||||
assert.false(range.contains(1, 21));
|
||||
assert.notOk(range.contains(0, 9));
|
||||
assert.notOk(range.contains(2, 9));
|
||||
assert.notOk(range.contains(1, 9));
|
||||
assert.notOk(range.contains(1, 21));
|
||||
},
|
||||
|
||||
"test: extend range": function() {
|
||||
|
|
@ -161,7 +161,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("../document").Document,
|
||||
var EditSession = require("ace/edit_session").EditSession,
|
||||
Search = require("../search").Search,
|
||||
assert = require("./assertions");
|
||||
|
||||
|
|
@ -51,128 +51,128 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: find simple text in document" : function() {
|
||||
var doc = new Document(["juhu kinners 123", "456"]);
|
||||
var session = new EditSession(["juhu kinners 123", "456"]);
|
||||
var search = new Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 5);
|
||||
assert.position(range.end, 0, 12);
|
||||
},
|
||||
|
||||
"test: find simple text in next line" : function() {
|
||||
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
var session = new EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
var search = new Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: find text starting at cursor position" : function() {
|
||||
var doc = new Document(["juhu kinners", "juhu kinners 123"]);
|
||||
doc.getSelection().moveCursorTo(0, 6);
|
||||
var session = new EditSession(["juhu kinners", "juhu kinners 123"]);
|
||||
session.getSelection().moveCursorTo(0, 6);
|
||||
var search = new Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: wrap search is off by default" : function() {
|
||||
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
doc.getSelection().moveCursorTo(2, 1);
|
||||
var session = new EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
session.getSelection().moveCursorTo(2, 1);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
assert.equal(search.find(doc), null);
|
||||
assert.equal(search.find(session), null);
|
||||
},
|
||||
|
||||
"test: wrap search should wrap at file end" : function() {
|
||||
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
doc.getSelection().moveCursorTo(2, 1);
|
||||
var session = new EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
session.getSelection().moveCursorTo(2, 1);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "kinners",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: wrap search with no match should return 'null'": function() {
|
||||
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
doc.getSelection().moveCursorTo(2, 1);
|
||||
var session = new EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
session.getSelection().moveCursorTo(2, 1);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "xyz",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
assert.equal(search.find(doc), null);
|
||||
assert.equal(search.find(session), null);
|
||||
},
|
||||
|
||||
"test: case sensitive is by default off": function() {
|
||||
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
var session = new EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "JUHU"
|
||||
});
|
||||
|
||||
assert.range(search.find(doc), 1, 0, 1, 4);
|
||||
assert.range(search.find(session), 1, 0, 1, 4);
|
||||
},
|
||||
|
||||
"test: case sensitive search": function() {
|
||||
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
var session = new EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "KINNERS",
|
||||
caseSensitive: true
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.equal(range, null);
|
||||
},
|
||||
|
||||
"test: whole word search should not match inside of words": function() {
|
||||
var doc = new Document(["juhukinners", "juhu kinners 123", "456"]);
|
||||
var session = new EditSession(["juhukinners", "juhu kinners 123", "456"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "kinners",
|
||||
wholeWord: true
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: find backwards": function() {
|
||||
var doc = new Document(["juhu juhu juhu juhu"]);
|
||||
doc.getSelection().moveCursorTo(0, 10);
|
||||
var session = new EditSession(["juhu juhu juhu juhu"]);
|
||||
session.getSelection().moveCursorTo(0, 10);
|
||||
var search = new Search().set({
|
||||
needle: "juhu",
|
||||
backwards: true
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 5);
|
||||
assert.position(range.end, 0, 9);
|
||||
},
|
||||
|
||||
"test: find in selection": function() {
|
||||
var doc = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||
doc.getSelection().setSelectionAnchor(1, 0);
|
||||
doc.getSelection().selectTo(3, 5);
|
||||
var session = new EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||
session.getSelection().setSelectionAnchor(1, 0);
|
||||
session.getSelection().selectTo(3, 5);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "juhu",
|
||||
|
|
@ -180,20 +180,20 @@ var Test = {
|
|||
scope: Search.SELECTION
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 0);
|
||||
assert.position(range.end, 1, 4);
|
||||
|
||||
doc.getSelection().setSelectionAnchor(0, 2);
|
||||
doc.getSelection().selectTo(3, 2);
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(3, 2);
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 0);
|
||||
assert.position(range.end, 1, 4);
|
||||
},
|
||||
|
||||
"test: find backwards in selection": function() {
|
||||
var doc = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||
var session = new EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "juhu",
|
||||
|
|
@ -202,36 +202,36 @@ var Test = {
|
|||
scope: Search.SELECTION
|
||||
});
|
||||
|
||||
doc.getSelection().setSelectionAnchor(0, 2);
|
||||
doc.getSelection().selectTo(3, 2);
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(3, 2);
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 2, 0);
|
||||
assert.position(range.end, 2, 4);
|
||||
|
||||
doc.getSelection().setSelectionAnchor(0, 2);
|
||||
doc.getSelection().selectTo(1, 2);
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(1, 2);
|
||||
|
||||
assert.equal(search.find(doc), null);
|
||||
assert.equal(search.find(session), null);
|
||||
},
|
||||
|
||||
"test: edge case - match directly before the cursor" : function() {
|
||||
var doc = new Document(["123", "123", "juhu"]);
|
||||
var session = new EditSession(["123", "123", "juhu"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "juhu",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
doc.getSelection().moveCursorTo(2, 5);
|
||||
session.getSelection().moveCursorTo(2, 5);
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 2, 0);
|
||||
assert.position(range.end, 2, 4);
|
||||
},
|
||||
|
||||
"test: edge case - match backwards directly after the cursor" : function() {
|
||||
var doc = new Document(["123", "123", "juhu"]);
|
||||
var session = new EditSession(["123", "123", "juhu"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "juhu",
|
||||
|
|
@ -239,28 +239,28 @@ var Test = {
|
|||
backwards: true
|
||||
});
|
||||
|
||||
doc.getSelection().moveCursorTo(2, 0);
|
||||
session.getSelection().moveCursorTo(2, 0);
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 2, 0);
|
||||
assert.position(range.end, 2, 4);
|
||||
},
|
||||
|
||||
"test: find using a regular expression" : function() {
|
||||
var doc = new Document(["abc123 123 cd", "abc"]);
|
||||
var session = new EditSession(["abc123 123 cd", "abc"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "\\d+",
|
||||
regExp: true
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 3);
|
||||
assert.position(range.end, 0, 6);
|
||||
},
|
||||
|
||||
"test: find using a regular expression and whole word" : function() {
|
||||
var doc = new Document(["abc123 123 cd", "abc"]);
|
||||
var session = new EditSession(["abc123 123 cd", "abc"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "\\d+\\b",
|
||||
|
|
@ -268,26 +268,26 @@ var Test = {
|
|||
wholeWord: true
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 7);
|
||||
assert.position(range.end, 0, 10);
|
||||
},
|
||||
|
||||
"test: use regular expressions with capture groups": function() {
|
||||
var doc = new Document([" ab: 12px", " <h1 abc"]);
|
||||
var session = new EditSession([" ab: 12px", " <h1 abc"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "(\\d+)",
|
||||
regExp: true
|
||||
});
|
||||
|
||||
var range = search.find(doc);
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 6);
|
||||
assert.position(range.end, 0, 8);
|
||||
},
|
||||
|
||||
"test: find all matches in selection" : function() {
|
||||
var doc = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||
var session = new EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||
|
||||
var search = new Search().set({
|
||||
needle: "uh",
|
||||
|
|
@ -295,10 +295,10 @@ var Test = {
|
|||
scope: Search.SELECTION
|
||||
});
|
||||
|
||||
doc.getSelection().setSelectionAnchor(0, 2);
|
||||
doc.getSelection().selectTo(3, 2);
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(3, 2);
|
||||
|
||||
var ranges = search.findAll(doc);
|
||||
var ranges = search.findAll(session);
|
||||
|
||||
assert.equal(ranges.length, 2);
|
||||
assert.position(ranges[0].start, 1, 1);
|
||||
|
|
@ -344,7 +344,7 @@ var Test = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test)
|
||||
module.exports = require("asyncjs/test").testcase(Test)
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -37,35 +37,35 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("../document").Document,
|
||||
var EditSession = require("ace/edit_session").EditSession,
|
||||
assert = require("./assertions");
|
||||
|
||||
var Test = {
|
||||
createTextDocument : function(rows, cols) {
|
||||
createSession : function(rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
return new Document(text);
|
||||
return new EditSession(text);
|
||||
},
|
||||
|
||||
"test: move cursor to end of file should place the cursor on last row and column" : function() {
|
||||
var doc = this.createTextDocument(200, 10);
|
||||
var selection = doc.getSelection();
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorFileEnd();
|
||||
assert.position(selection.getCursor(), 199, 10);
|
||||
},
|
||||
|
||||
"test: moveCursor to start of file should place the cursor on the first row and column" : function() {
|
||||
var doc = this.createTextDocument(200, 10);
|
||||
var selection = doc.getSelection();
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorFileStart();
|
||||
assert.position(selection.getCursor(), 0, 0);
|
||||
},
|
||||
|
||||
"test: move selection lead to end of file" : function() {
|
||||
var doc = this.createTextDocument(200, 10);
|
||||
var selection = doc.getSelection();
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(100, 5);
|
||||
selection.selectFileEnd();
|
||||
|
|
@ -77,8 +77,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: move selection lead to start of file" : function() {
|
||||
var doc = this.createTextDocument(200, 10);
|
||||
var selection = doc.getSelection();
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(100, 5);
|
||||
selection.selectFileStart();
|
||||
|
|
@ -90,9 +90,9 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: move cursor word right" : function() {
|
||||
var doc = new Document( ["ab",
|
||||
var session = new EditSession( ["ab",
|
||||
" Juhu Kinners (abc, 12)", " cde"].join("\n"));
|
||||
var selection = doc.getSelection();
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorDown();
|
||||
assert.position(selection.getCursor(), 1, 0);
|
||||
|
|
@ -130,8 +130,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: select word right if cursor in word" : function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 2);
|
||||
selection.moveCursorWordRight();
|
||||
|
|
@ -140,9 +140,9 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: moveCursor word left" : function() {
|
||||
var doc = new Document( ["ab",
|
||||
var session = new EditSession( ["ab",
|
||||
" Juhu Kinners (abc, 12)", " cde"].join("\n"));
|
||||
var selection = doc.getSelection();
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorDown();
|
||||
selection.moveCursorLineEnd();
|
||||
|
|
@ -181,8 +181,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: select word left if cursor in word" : function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 8);
|
||||
|
||||
|
|
@ -191,8 +191,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: select word right and select" : function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 0);
|
||||
selection.selectWordRight();
|
||||
|
|
@ -204,8 +204,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: select word left and select" : function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 3);
|
||||
selection.selectWordLeft();
|
||||
|
|
@ -217,8 +217,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: select word with cursor in word should select the word" : function() {
|
||||
var doc = new Document("Juhu Kinners 123");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners 123");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 8);
|
||||
selection.selectWord();
|
||||
|
|
@ -229,8 +229,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: select word with cursor betwen white space and word should select the word" : function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 4);
|
||||
selection.selectWord();
|
||||
|
|
@ -248,8 +248,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: select word with cursor in white space should select white space" : function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
selection.selectWord();
|
||||
|
|
@ -260,8 +260,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: moving cursor should fire a 'changeCursor' event" : function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
|
||||
|
|
@ -271,12 +271,12 @@ var Test = {
|
|||
});
|
||||
|
||||
selection.moveCursorTo(0, 6);
|
||||
assert.true(called);
|
||||
assert.ok(called);
|
||||
},
|
||||
|
||||
"test: calling setCursor with the same position should not fire an event": function() {
|
||||
var doc = new Document("Juhu Kinners");
|
||||
var selection = doc.getSelection();
|
||||
var session = new EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
|
||||
|
|
@ -286,11 +286,11 @@ var Test = {
|
|||
});
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
assert.false(called);
|
||||
assert.notOk(called);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
define(function(require, exports, module) {
|
||||
require("./mockdom");
|
||||
|
||||
var Document = require("../document").Document,
|
||||
var EditSession = require("ace/edit_session").EditSession,
|
||||
Editor = require("../editor").Editor,
|
||||
JavaScriptMode = require("../mode/javascript").Mode,
|
||||
UndoManager = require("../undomanager").UndoManager,
|
||||
|
|
@ -47,74 +47,74 @@ var Document = require("../document").Document,
|
|||
|
||||
var Test = {
|
||||
"test: delete line from the middle" : function() {
|
||||
var doc = new Document(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(doc.toString(), "a\nc\nd");
|
||||
assert.equal(session.toString(), "a\nc\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(doc.toString(), "a\nd");
|
||||
assert.equal(session.toString(), "a\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(doc.toString(), "a\n");
|
||||
assert.equal(session.toString(), "a\n");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(doc.toString(), "a\n");
|
||||
assert.equal(session.toString(), "a\n");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
},
|
||||
|
||||
"test: delete multiple selected lines" : function() {
|
||||
var doc = new Document(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(doc.toString(), "a\nd");
|
||||
assert.equal(session.toString(), "a\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
},
|
||||
|
||||
"test: delete first line" : function() {
|
||||
var doc = new Document(["a", "b", "c"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["a", "b", "c"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(doc.toString(), "b\nc");
|
||||
assert.equal(session.toString(), "b\nc");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
},
|
||||
|
||||
"test: delete last" : function() {
|
||||
var doc = new Document(["a", "b", "c"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["a", "b", "c"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(2, 1);
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(doc.toString(), "a\nb\n");
|
||||
assert.equal(session.toString(), "a\nb\n");
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
},
|
||||
|
||||
"test: indent block" : function() {
|
||||
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 3);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
|
||||
assert.equal(["a12345", " b12345", " c12345"].join("\n"), doc.toString());
|
||||
assert.equal(["a12345", " b12345", " c12345"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 2, 7);
|
||||
|
||||
|
|
@ -124,35 +124,35 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: indent selected lines" : function() {
|
||||
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
assert.equal(["a12345", " b12345", "c12345"].join("\n"), doc.toString());
|
||||
},
|
||||
var session = new EditSession(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
assert.equal(["a12345", " b12345", "c12345"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: no auto indent if cursor is before the {" : function() {
|
||||
var doc = new Document("{", new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession("{", new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.onTextInput("\n");
|
||||
assert.equal(["", "{"].join("\n"), doc.toString());
|
||||
assert.equal(["", "{"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: outdent block" : function() {
|
||||
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession([" a12345", " b12345", " c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.blockOutdent();
|
||||
assert.equal(doc.toString(), [" a12345", "b12345", " c12345"].join("\n"));
|
||||
assert.equal(session.toString(), [" a12345", "b12345", " c12345"].join("\n"));
|
||||
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ var Test = {
|
|||
assert.position(range.end, 2, 1);
|
||||
|
||||
editor.blockOutdent();
|
||||
assert.equal(doc.toString(), ["a12345", "b12345", "c12345"].join("\n"));
|
||||
assert.equal(session.toString(), ["a12345", "b12345", "c12345"].join("\n"));
|
||||
|
||||
var range = editor.getSelectionRange();
|
||||
assert.position(range.start, 0, 0);
|
||||
|
|
@ -169,25 +169,25 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: outent without a selection should update cursor" : function() {
|
||||
var doc = new Document(" 12");
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(" 12");
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 3);
|
||||
editor.blockOutdent(" ");
|
||||
|
||||
assert.equal(doc.toString(), " 12");
|
||||
assert.equal(session.toString(), " 12");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
},
|
||||
|
||||
"test: comment lines should perserve selection" : function() {
|
||||
var doc = new Document([" abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession([" abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 2);
|
||||
editor.getSelection().selectDown();
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal(["// abc", "//cde"].join("\n"), doc.toString());
|
||||
assert.equal(["// abc", "//cde"].join("\n"), session.toString());
|
||||
|
||||
var selection = editor.getSelectionRange();
|
||||
assert.position(selection.start, 0, 4);
|
||||
|
|
@ -195,8 +195,8 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: uncomment lines should perserve selection" : function() {
|
||||
var doc = new Document(["// abc", "//cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["// abc", "//cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
|
@ -205,13 +205,13 @@ var Test = {
|
|||
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal([" abc", "cde"].join("\n"), doc.toString());
|
||||
assert.equal([" abc", "cde"].join("\n"), session.toString());
|
||||
assert.range(editor.getSelectionRange(), 0, 0, 1, 1);
|
||||
},
|
||||
|
||||
"test: toggle comment lines twice should return the original text" : function() {
|
||||
var doc = new Document([" abc", "cde", "fg"], new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession([" abc", "cde", "fg"], new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
|
@ -220,14 +220,14 @@ var Test = {
|
|||
editor.toggleCommentLines();
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
|
||||
"test: comment lines - if the selection end is at the line start it should stay there": function() {
|
||||
//select down
|
||||
var doc = new Document(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
|
@ -236,8 +236,8 @@ var Test = {
|
|||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||
|
||||
// select up
|
||||
var doc = new Document(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectUp();
|
||||
|
|
@ -247,47 +247,47 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: move lines down should select moved lines" : function() {
|
||||
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "11", "22", "44"].join("\n"), doc.toString());
|
||||
assert.equal(["33", "11", "22", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), doc.toString());
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||
|
||||
// moving again should have no effect
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), doc.toString());
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||
},
|
||||
|
||||
"test: move lines up should select moved lines" : function() {
|
||||
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(2, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(doc.toString(), ["11", "33", "44", "22"].join("\n"));
|
||||
assert.equal(session.toString(), ["11", "33", "44", "22"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(doc.toString(), ["33", "44", "11", "22"].join("\n"));
|
||||
assert.equal(session.toString(), ["33", "44", "11", "22"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 0, 0);
|
||||
|
|
@ -295,32 +295,32 @@ var Test = {
|
|||
|
||||
"test: move line without active selection should move cursor to start of the moved line" : function()
|
||||
{
|
||||
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.clearSelection();
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["11", "33", "22", "44"].join("\n"), doc.toString());
|
||||
assert.equal(["11", "33", "22", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
|
||||
editor.clearSelection();
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(["11", "22", "33", "44"].join("\n"), doc.toString());
|
||||
assert.equal(["11", "22", "33", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
},
|
||||
|
||||
"test: copy lines down should select lines and place cursor at the selection start" : function() {
|
||||
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.copyLinesDown();
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), doc.toString());
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 5, 0);
|
||||
|
|
@ -328,14 +328,14 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: copy lines up should select lines and place cursor at the selection start" : function() {
|
||||
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.copyLinesUp();
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), doc.toString());
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
|
|
@ -343,105 +343,102 @@ var Test = {
|
|||
},
|
||||
|
||||
"test: input a tab with soft tab should convert it to spaces" : function() {
|
||||
var doc = new Document("");
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession("");
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
doc.setTabSize(2);
|
||||
doc.setUseSoftTabs(true);
|
||||
session.setTabSize(2);
|
||||
session.setUseSoftTabs(true);
|
||||
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(doc.toString(), " ");
|
||||
assert.equal(session.toString(), " ");
|
||||
|
||||
doc.setTabSize(5);
|
||||
session.setTabSize(5);
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(doc.toString(), " ");
|
||||
assert.equal(session.toString(), " ");
|
||||
},
|
||||
|
||||
"test: input tab without soft tabs should keep the tab character" : function() {
|
||||
var doc = new Document("");
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var session = new EditSession("");
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
doc.setUseSoftTabs(false);
|
||||
session.setUseSoftTabs(false);
|
||||
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(doc.toString(), "\t");
|
||||
assert.equal(session.toString(), "\t");
|
||||
},
|
||||
|
||||
"test: undo/redo for delete line" : function() {
|
||||
var doc = new Document(["111", "222", "333"]);
|
||||
var session = new EditSession(["111", "222", "333"]);
|
||||
var undoManager = new UndoManager();
|
||||
doc.setUndoManager(undoManager);
|
||||
session.setUndoManager(undoManager);
|
||||
|
||||
var initialText = doc.toString();
|
||||
|
||||
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var initialText = session.toString();
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.removeLines();
|
||||
var step1 = doc.toString();
|
||||
var step1 = session.toString();
|
||||
assert.equal(step1, "222\n333");
|
||||
doc.$informUndoManager.call();
|
||||
session.$informUndoManager.call();
|
||||
|
||||
editor.removeLines();
|
||||
var step2 = doc.toString();
|
||||
var step2 = session.toString();
|
||||
assert.equal(step2, "333");
|
||||
doc.$informUndoManager.call();
|
||||
session.$informUndoManager.call();
|
||||
|
||||
editor.removeLines();
|
||||
var step3 = doc.toString();
|
||||
var step3 = session.toString();
|
||||
assert.equal(step3, "");
|
||||
doc.$informUndoManager.call();
|
||||
session.$informUndoManager.call();
|
||||
|
||||
|
||||
undoManager.undo();
|
||||
doc.$informUndoManager.call();
|
||||
assert.equal(doc.toString(), step2);
|
||||
session.$informUndoManager.call();
|
||||
assert.equal(session.toString(), step2);
|
||||
|
||||
undoManager.undo();
|
||||
doc.$informUndoManager.call();
|
||||
assert.equal(doc.toString(), step1);
|
||||
session.$informUndoManager.call();
|
||||
assert.equal(session.toString(), step1);
|
||||
|
||||
undoManager.undo();
|
||||
doc.$informUndoManager.call();
|
||||
assert.equal(doc.toString(), initialText);
|
||||
session.$informUndoManager.call();
|
||||
assert.equal(session.toString(), initialText);
|
||||
|
||||
undoManager.undo();
|
||||
doc.$informUndoManager.call();
|
||||
assert.equal(doc.toString(), initialText);
|
||||
session.$informUndoManager.call();
|
||||
assert.equal(session.toString(), initialText);
|
||||
},
|
||||
|
||||
"test: remove left should remove character left of the cursor" : function() {
|
||||
var doc = new Document(["123", "456"]);
|
||||
var session = new EditSession(["123", "456"]);
|
||||
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.removeLeft();
|
||||
assert.equal(doc.toString(), "123\n56");
|
||||
assert.equal(session.toString(), "123\n56");
|
||||
},
|
||||
|
||||
"test: remove left should remove line break if cursor is at line start" : function() {
|
||||
var doc = new Document(["123", "456"]);
|
||||
var session = new EditSession(["123", "456"]);
|
||||
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.removeLeft();
|
||||
assert.equal(doc.toString(), "123456");
|
||||
assert.equal(session.toString(), "123456");
|
||||
},
|
||||
|
||||
"test: remove left should remove tabsize spaces if cursor is on a tab stop and preceeded by spaces" : function() {
|
||||
var doc = new Document(["123", " 456"]);
|
||||
doc.setUseSoftTabs(true);
|
||||
doc.setTabSize(4);
|
||||
var session = new EditSession(["123", " 456"]);
|
||||
session.setUseSoftTabs(true);
|
||||
session.setTabSize(4);
|
||||
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
editor.moveCursorTo(1, 8);
|
||||
editor.removeLeft();
|
||||
assert.equal(doc.toString(), "123\n 456");
|
||||
},
|
||||
|
||||
assert.equal(session.toString(), "123\n 456");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
define(function(require, exports, module) {
|
||||
require("./mockdom");
|
||||
|
||||
var Document = require("../document").Document,
|
||||
var EditSession = require("ace/edit_session").EditSession,
|
||||
VirtualRenderer = require("../virtual_renderer").VirtualRenderer,
|
||||
assert = require("./assertions");
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ var Test = {
|
|||
document.body.appendChild(el);
|
||||
|
||||
var renderer = new VirtualRenderer(el);
|
||||
renderer.setDocument(new Document("1234"));
|
||||
renderer.setSession(new EditSession("1234"));
|
||||
|
||||
renderer.characterWidth = 10;
|
||||
renderer.lineHeight = 15;
|
||||
|
|
@ -72,7 +72,7 @@ var Test = {
|
|||
// change tab size after setDocument (for text layer)
|
||||
};
|
||||
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module.exports = require("asyncjs/test").testcase(Test);
|
||||
});
|
||||
|
||||
if (module === require.main) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-clouds .ace_editor .ace_printMargin {\
|
||||
.ace-clouds .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-clouds-midnight .ace_editor .ace_printMargin {\
|
||||
.ace-clouds-midnight .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-cobalt .ace_editor .ace_printMargin {\
|
||||
.ace-cobalt .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-dawn .ace_editor .ace_printMargin {\
|
||||
.ace-dawn .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-idle-fingers .ace_editor .ace_printMargin {\
|
||||
.ace-idle-fingers .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-kr-theme .ace_editor .ace_printMargin {\
|
||||
.ace-kr-theme .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-mono-industrial .ace_editor .ace_printMargin {\
|
||||
.ace-mono-industrial .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-monokai .ace_editor .ace_printMargin {\
|
||||
.ace-monokai .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,7 +63,7 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-pastel-on-dark .ace_editor .ace_printMargin {\
|
||||
.ace-pastel-on-dark .ace_print_margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.ace-tm .ace_editor .ace_printMargin {
|
||||
.ace-tm .ace_print_margin {
|
||||
width: 1px;
|
||||
background: #e8e8e8;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -63,9 +63,10 @@ define(function(require, exports, module) {
|
|||
padding-right: 6px;\
|
||||
}\
|
||||
\
|
||||
.ace-twilight .ace_editor .ace_printMargin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
.ace-twilight .ace_print_margin {\
|
||||
border-left: 1px solid #3C3C3C;\
|
||||
width: 100%;\
|
||||
background: #242424;\
|
||||
}\
|
||||
\
|
||||
.ace-twilight .ace_scroller {\
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
|
|
@ -44,11 +44,6 @@ var UndoManager = function() {
|
|||
|
||||
(function() {
|
||||
|
||||
/*this.$doc = null;
|
||||
this.setDocument = function(doc) {
|
||||
this.$doc = doc;
|
||||
};*/
|
||||
|
||||
this.execute = function(options) {
|
||||
var deltas = options.args[0];
|
||||
this.$doc = options.args[1];
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@
|
|||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -67,7 +68,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.container.appendChild(this.scroller);
|
||||
|
||||
this.content = document.createElement("div");
|
||||
this.content.style.position = "absolute";
|
||||
this.content.style.cssText = "position:absolute;box-sizing:border-box;" +
|
||||
"-moz-box-sizing:border-box;-webkit-box-sizing:border-box";
|
||||
this.scroller.appendChild(this.content);
|
||||
|
||||
this.$gutterLayer = new GutterLayer(this.$gutter);
|
||||
|
|
@ -132,12 +134,11 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
this.lines = doc.lines;
|
||||
this.doc = doc;
|
||||
this.$cursorLayer.setDocument(doc);
|
||||
this.$markerLayer.setDocument(doc);
|
||||
this.$textLayer.setDocument(doc);
|
||||
this.setSession = function(session) {
|
||||
this.session = session;
|
||||
this.$cursorLayer.setSession(session);
|
||||
this.$markerLayer.setSession(session);
|
||||
this.$textLayer.setSession(session);
|
||||
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
};
|
||||
|
|
@ -193,7 +194,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.scroller.style.height = height + "px";
|
||||
this.scrollBar.setHeight(height);
|
||||
|
||||
if (this.doc) {
|
||||
if (this.session) {
|
||||
this.scrollToY(this.getScrollTop());
|
||||
changes = changes | this.CHANGE_FULL;
|
||||
}
|
||||
|
|
@ -229,16 +230,13 @@ var VirtualRenderer = function(container, theme) {
|
|||
});
|
||||
};
|
||||
|
||||
this.$showInvisibles = true;
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
this.$showInvisibles = showInvisibles;
|
||||
this.$textLayer.setShowInvisibles(showInvisibles);
|
||||
|
||||
this.$loop.schedule(this.CHANGE_TEXT);
|
||||
if (this.$textLayer.setShowInvisibles(showInvisibles))
|
||||
this.$loop.schedule(this.CHANGE_TEXT);
|
||||
};
|
||||
|
||||
this.getShowInvisibles = function() {
|
||||
return this.$showInvisibles;
|
||||
return this.$textLayer.showInvisibles;
|
||||
};
|
||||
|
||||
this.$showPrintMargin = true;
|
||||
|
|
@ -268,13 +266,17 @@ var VirtualRenderer = function(container, theme) {
|
|||
}
|
||||
|
||||
this.$updatePrintMargin = function() {
|
||||
var containerEl
|
||||
|
||||
if (!this.$showPrintMargin && !this.$printMarginEl)
|
||||
return;
|
||||
|
||||
if (!this.$printMarginEl) {
|
||||
this.$printMarginEl = document.createElement("div");
|
||||
this.$printMarginEl.className = "ace_printMargin";
|
||||
this.content.insertBefore(this.$printMarginEl, this.$textLayer.element);
|
||||
containerEl = document.createElement("div");
|
||||
containerEl.className = "ace_print_margin_layer";
|
||||
this.$printMarginEl = document.createElement("div")
|
||||
this.$printMarginEl.className = "ace_print_margin";
|
||||
containerEl.appendChild(this.$printMarginEl);
|
||||
this.content.insertBefore(containerEl, this.$textLayer.element);
|
||||
}
|
||||
|
||||
var style = this.$printMarginEl.style;
|
||||
|
|
@ -325,12 +327,12 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.$updateScrollBar = function() {
|
||||
this.scrollBar.setInnerHeight(this.doc.getLength() * this.lineHeight);
|
||||
this.scrollBar.setInnerHeight(this.session.getLength() * this.lineHeight);
|
||||
this.scrollBar.setScrollTop(this.scrollTop);
|
||||
};
|
||||
|
||||
this.$renderChanges = function(changes) {
|
||||
if (!changes || !this.doc || !this.$tokenizer)
|
||||
if (!changes || !this.session || !this.$tokenizer)
|
||||
return;
|
||||
|
||||
// text, scrolling and resize changes can cause the view port size to change
|
||||
|
|
@ -398,7 +400,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
var lineCount = Math.ceil(minHeight / this.lineHeight);
|
||||
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
|
||||
var lastRow = Math.max(0, Math.min(this.lines.length, firstRow + lineCount) - 1);
|
||||
var lastRow = Math.max(0, Math.min(this.session.getLength(), firstRow + lineCount) - 1);
|
||||
|
||||
var layerConfig = this.layerConfig = {
|
||||
width : longestLine,
|
||||
|
|
@ -412,14 +414,6 @@ var VirtualRenderer = function(container, theme) {
|
|||
height : this.$size.scrollerHeight
|
||||
};
|
||||
|
||||
for ( var i = 0; i < this.layers.length; i++) {
|
||||
var layer = this.layers[i];
|
||||
if (widthChanged) {
|
||||
var style = layer.element.style;
|
||||
style.width = longestLine + "px";
|
||||
}
|
||||
};
|
||||
|
||||
this.$gutterLayer.element.style.marginTop = (-offset) + "px";
|
||||
this.content.style.marginTop = (-offset) + "px";
|
||||
this.content.style.width = longestLine + "px";
|
||||
|
|
@ -452,8 +446,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.$getLongestLine = function() {
|
||||
var charCount = this.doc.getScreenWidth();
|
||||
if (this.$showInvisibles)
|
||||
var charCount = this.session.getScreenWidth();
|
||||
if (this.$textLayer.showInvisibles)
|
||||
charCount += 1;
|
||||
|
||||
return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(charCount * this.characterWidth));
|
||||
|
|
@ -541,7 +535,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
var maxHeight = this.lines.length * this.lineHeight - this.$size.scrollerHeight;
|
||||
var maxHeight = this.session.getLength() * this.lineHeight - this.$size.scrollerHeight;
|
||||
var scrollTop = Math.max(0, Math.min(maxHeight, scrollTop));
|
||||
|
||||
if (this.scrollTop !== scrollTop) {
|
||||
|
|
@ -572,14 +566,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
return {
|
||||
row : row,
|
||||
column : this.doc.screenToDocumentColumn(Math.max(0, Math.min(row, this.doc.getLength()-1)), col)
|
||||
column : this.session.screenToDocumentColumn(Math.max(0, Math.min(row, this.session.getLength()-1)), col)
|
||||
};
|
||||
};
|
||||
|
||||
this.textToScreenCoordinates = function(row, column) {
|
||||
var canvasPos = this.scroller.getBoundingClientRect();
|
||||
|
||||
var x = this.padding + Math.round(this.doc.documentToScreenColumn(row, column) * this.characterWidth);
|
||||
var x = this.$padding + Math.round(this.session.documentToScreenColumn(row, column) * this.characterWidth);
|
||||
var y = row * this.lineHeight;
|
||||
|
||||
return {
|
||||
|
|
|
|||
26
package.json
26
package.json
|
|
@ -1,17 +1,31 @@
|
|||
{
|
||||
"name": "ace",
|
||||
"description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE",
|
||||
"version": "0.1",
|
||||
"version": "0.1.0",
|
||||
"homepage" : "http://github.com/ajaxorg/ace",
|
||||
"engines": {"node": ">= 0.1.102"},
|
||||
"engines": {"node": ">= 0.2.0"},
|
||||
"author": "Fabian Jakobs <fabian@ajax.org>",
|
||||
"main": "src/ace/ace",
|
||||
"main": "lib/ace",
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "http://github.com/ajaxorg/ace.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"asyncjs": ">=0.0.2",
|
||||
"jsdom": ">=0.1.23",
|
||||
"htmlparser": ">=1.7.2",
|
||||
"dryice": ">=0.1.0"
|
||||
},
|
||||
"licenses": [{
|
||||
"type": "LGPLv3",
|
||||
"url": "http://www.gnu.org/licenses/lgpl-3.0.txt"}
|
||||
]
|
||||
"type": "MPL",
|
||||
"url": "http://www.mozilla.org/MPL/"
|
||||
},
|
||||
{
|
||||
"type": "GPL",
|
||||
"url": "http://www.gnu.org/licenses/gpl.html"
|
||||
},
|
||||
{
|
||||
"type": "LGPL",
|
||||
"url": "http://www.gnu.org/licenses/lgpl.html"
|
||||
}]
|
||||
}
|
||||
2
static.py
Normal file → Executable file
2
static.py
Normal file → Executable file
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2.4
|
||||
#!/usr/bin/env python
|
||||
"""static - A stupidly simple WSGI way to serve static (or mixed) content.
|
||||
|
||||
(See the docstrings of the various functions and classes.)
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 6da8076355fc9f06191d39b8f5989159dc8a162c
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 36c55c39e8ede94e964364e01ab5308f3f51c2eb
|
||||
Subproject commit dbc78536a4ea61e0f762067fb847213526500d9f
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 44b0e97e8a01cef9f29c5ceedd2a12ae9e6fe540
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 486755962dc0b69c60bfd04869ff1e0093406bae
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 60d64db4a9a8b1a26bd099bc34f657bf096c4f39
|
||||
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