fixed: #9897. Fixed problem with highlighting in codearea. Updated EditArea to version 0.8.1.1

This commit is contained in:
Doug Bell 2009-05-01 18:29:41 +00:00
parent bbbe385889
commit 3320465ca4
66 changed files with 3122 additions and 2275 deletions

View file

@ -157,6 +157,7 @@ sub toHtml {
id : "$id",
syntax : "$syntax",
start_highlight : true,
show_line_colors: true,
toolbar : "search, go_to_line, |, undo, redo, |, syntax_selection, highlight, reset_highlight, |, help"
});
</script>

View file

@ -1,3 +1,50 @@
**** v 0.8.1.1 ****
- Fix bug of frequent syntax desynchronisation when the first character of the textarea was highlighted
- In unload now check that parent.editareaLoader still exists before calling it
- Now consider that gecko and webkit based browser are valid browsers (but I won't test them all)
**** v 0.8.1 ****
- Improved speed of text highlighting process for huge file. Now we try to only insert or delete the changed caracters inside DOM text node instead of refreshing the whole area. (3 time faster in firefox)
- Greatly improved speed of line-height management in word-wrap context
- Add java syntax (thanks to Dawson Goodell)
- Use faster regexp for matching quoted strings
- Bug fix: if a highlighted quote or comment string contains cariage return, editing text on one of the lines was causin a highlight desynchronisation
- Bug fix: text war blur on Safari 3.2 (thanks to spellcoder)
- Bug fix: there had several mistake with non-monospace font (thanks to spellcoder)
- Bug fix: if show_line_colors was disabled and word wrap enable, highlighted text wasn't refreshed if a new line appears
- Bug fix: in multi file edition, closing the last tab was throwing an error in Firefox and let the content of the textarea displayed
- Browser bug detection: when using non-monospace font Firefox will sometime have strange behavior on text-width (the highlighted text-width in the background may change fron textarea one and simply can change after beeing updated); look likes a browser rendering bug
**** v 0.8 ****
- Word-wrap is now supported (except for opera...). The new init() option is 'word_wrap' to set to 'true' (default is false). A new button appears in the default toolbar (button_code: 'word_wrap' )
- We can now clearly see the selected text
- Add Internet explorer 8 support (but sadly I must use IE7 emulate mode in iframe due to a bug with tabulation width not beeing resized in IE's textarea)
- Add Safari 4 support
- Add Chrome 2 support
- Better support of Opera 9.6
- Add Simplified Chinese translation "zh" (thanks to Abentian)
- Add Bulgarian translation "bg" (thanks to Valentin Hristov)
- Rename internal function $() by _$()
- Delete EditArea.add_event() method (duplicate af editAreaLoader.add_event() method)
- Do some code cleanup-up
- Bug fix: highlight optimisation process was not working under IE (don't known how long it remain broken but must be since a long time)
- Bug fix: EditArea.update_size sometimes uses undefined variable (fix this possibility and cleanup events)
- Bug fix: Template.html was not valid XHTML
- Bug fix: The checked attribute of the toogle button was not defined in xhtml syntax
- Bug fix: If the editArea was loaded on a page related to a domain which was itself an iframe comming from another domain a JS error was thrown on load
- Bug fix: When EditArea is used to replace a textarea which has style="visibility:hidden;", switching off EditArea would throw an error under IE
**** v 0.7.3 ****
- Add Finnish transaltion (thanks to Janne Mäntyharju)
- Add 'cursor_position' init() option for defining where the cursor should be when the editor is show on the first time ('auto' or 'begin'). This was like 'auto' before now this is like 'begin' by default
- better add_style method (faster than old one) thanks to Spellcoder
- Bug fix: fix bug with mootools 1.2
- Bug fix: if page had no stylesheets when editarea load, it would generate an error
**** v 0.7.2.3 ****
- it's now released under both LGPL, Apache, BSD license (you can use the one you prefer)
- add support for bonEcho browser
**** v 0.7.2.2 ****
- Fix bug regression introduced in 0.7.2 that make IE7 not working
- add Esperento translation (thanks to Olivier)

View file

@ -1,48 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>EditArea documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="doc_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='header'>
<h1>About</h1>
</div>
<div class='content'>
<h2>General information</h2>
<p>EditArea is a free javascript editor for source code. It allow to write
well formated source code. That's no way a WYSIWYG editor.
</p>
<p>
EditArea is developed by Christophe Dolivet
(<a href='http://www.cdolivet.net/index.php?page=Contact'>contact</a>)
and is currently released
under the "LGPL" license, read the license agreement for details.
</p>
<h2>Features</h2>
<ul>
<li>Easy to integrate, takes only a couple lines of code.</li>
<li>Live syntax highlight.</li>
<li>Search and replace (with regexp).</li>
<li>Line numerotation.</li>
<li>International language support.</li>
<li>Allow to create new syntax or translation files.</li>
<li>Multiple instance on the same page.</li>
<li>Multiple browser support (see <a href='compatibility.html'>compatibility chart</a>
for more information).</li>
<li>Font resizing.</li>
<li>Toolbar customization.</li>
<li>Load and save callback function.</li>
<li>Possibility to use a gzip compressed version of the script (only 20Kb).</li>
</ul>
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<br style="clear: both" />
</div>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>EditArea documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="doc_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='header'>
<h1>About</h1>
</div>
<div class='content'>
<h2>General information</h2>
<p>EditArea is a free javascript editor for source code. It allow to write
well formated source code. That's no way a WYSIWYG editor.
</p>
<p>
EditArea is developed by Christophe Dolivet
and is currently released
under the "LGPL", "Apache" and "BSD" licenses (use the one you want), read the licenses agreement for details.
</p>
<h2>Features</h2>
<ul>
<li>Easy to integrate, only one script include and one function call</li>
<li>Tabulation support (allow to write well formated source code)</li>
<li>Customizable real-time syntax highlighting (currently: PHP, CSS, Javascript, Python, HTML, XML, VB, C, CPP, SQL, Pascal, Basic, Brainf*ck, and probably more...)</li>
<li>Word-wrap support</li>
<li>Search and replace (with regexp)</li>
<li>Auto-indenting new lines</li>
<li>Line numerotation</li>
<li>Multilanguage support (currently: Croatian, Czech, Danish, Dutch, English, Esperanto, French, German, Italian, Japanese, Macedonian, Polish, Portuguese, Russian, Slovak, Spanish, and probably more...)</li>
<li>Possible PHP gzip compression (compress the core files to one file of ~25Ko)</li>
<li>Allow multiple instances</li>
<li>Full screen mode</li>
<li>Possible plugin integration</li>
<li>Possible save and load callback functions</li>
<li>Possible dynamic content management</li>
<li>Can work in the same environment than "prototype" and "mootools"'s like libraries.</li>
</ul>
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>
</html>

View file

@ -19,7 +19,7 @@
The table was reset to only show the browsers I take care of.
</p>
<p> Since I have no mac, I can't make test for safari, neither testing multi-plateform browsers.
<p> Since I have no mac and currently have no computer under linux, I can't testing multi-plateform browsers.
Let me know if you constat that such browsers are working.
</p>
<p>
@ -31,31 +31,31 @@
<td>MacOS X</td>
</tr>
<tr>
<td>MSIE 7 & 6</td>
<td>MSIE 6 & 7 & 8</td>
<td>OK</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Firefox 3 & 2 & 1.5</td>
<td>Firefox 1.5 & 2 & 3</td>
<td>OK</td>
<td>OK</td>
<td>OK</td>
</tr>
<tr>
<td>Safari 3.0 & 3.1</td>
<td>Safari 3.0 & 3.1 & 4</td>
<td>OK</td>
<td>&nbsp;</td>
<td>OK</td>
</tr>
<tr>
<td>Chrome</td>
<td>Chrome 1 & 2</td>
<td>OK</td>
<td>???</td>
<td>???</td>
</tr>
<tr>
<td>Opera 9 & 9.5</td>
<td>Opera 9 & 9.6</td>
<td>OK</td>
<td>OK</td>
<td>OK</td>
@ -83,7 +83,7 @@
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -73,10 +73,10 @@
<br /><span class='underline'>Default</span>: "onload"
</li>
<li><strong>toolbar</strong>: define the toolbar that will be displayed, each element being separated by a ",".
<br /><span class='underline'>Type</span>: String (combinaison of: "|", "*", "search", "go_to_line", "undo", "redo", "change_smooth_selection", "reset_highlight", "highlight", "help", "save", "load", "new_document", "syntax_selection")
<br /><span class='underline'>Type</span>: String (combinaison of: "|", "*", "search", "go_to_line", "undo", "redo", "change_smooth_selection", "reset_highlight", "highlight", "word_wrap", "help", "save", "load", "new_document", "syntax_selection")
<br />"|" or "separator" make appears a separator in the toolbar.
<br />"*" or "return" make appears a line-break in the toolbar
<br /><span class='underline'>Default</span>: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, |, help"
<br /><span class='underline'>Default</span>: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
</li>
<li><strong>begin_toolbar</strong>: toolbar button list to add before the toolbar defined by the "toolbar" option.
<br /><span class='underline'>Type</span>: String (cf. "toolbar" option)
@ -94,6 +94,9 @@
<br /><span class='underline'>Type</span>: String
<br /><span class='underline'>Default</span>: "monospace"
</li>
<li><strong>cursor_position</strong>: define if the cursor should be placed where it was in the textarea before replacement (auto) or at the beginning of the file (begin).
<br /><span class='underline'>Type</span>: String ("begin" or "auto")
<br /><span class='underline'>Default</span>: "begin"
</li>
<li><strong>gecko_spellcheck</strong>: allow to disable/enable the Firefox 2 spellchecker
<br /><span class='underline'>Type</span>: Boolean
@ -112,6 +115,11 @@
<br /><span class='underline'>Type</span>: Boolean
<br /><span class='underline'>Default</span>: true
</li>
<li><strong>word_wrap</strong>: determine if the text will be automatically wrapped to the next line when it reach the end of a line. This is linked ot the word_wrap icon available in the toolbar.
<br /><span class='underline'>Type</span>: Boolean
<br /><span class='underline'>Default</span>: false
</li>
<li><strong>replace_tab_by_spaces</strong>: define the number of spaces that will replace tabulations (\t) in text. If tabulation should stay tabulation, set this option to false.
<br /><span class='underline'>Type</span>: Integer (or false)
<br /><span class='underline'>Default</span>: false
@ -209,7 +217,7 @@ editAreaLoader.init({
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -27,21 +27,25 @@
<ul>
<li>Global help
<ul>
<li>Gildas Noël</li>
<li>Gildas Noël</li>
<li>Spellcoder</li>
</ul>
</li>
<li>Languages translation
<ul>
<li>Olaf Brambrink &amp; Felix Riesterer &amp; Christoph Pinkel (deutsh)</li>
<li>Peter Klein (danish)</li>
<li>Leonardo Sapucaia (portuguese)</li>
<li>Ishitoya Kentaro (japanese)</li>
<li>Piotr Furman (polish)</li>
<li>Luciano Vernaschi (italian)</li>
<li>Ivan Vucica and Davor Cihlar (croatian)</li>
<li>Garito (spanish)</li>
<li>Gabriel Schwardy (slovak)</li>
<li>Olivier (esperento)</li>
<li>Olaf Brambrink &amp; Felix Riesterer &amp; Christoph Pinkel (Deutsh)</li>
<li>Peter Klein (Danish)</li>
<li>Leonardo Sapucaia (Portuguese)</li>
<li>Ishitoya Kentaro (Japanese)</li>
<li>Piotr Furman (Polish)</li>
<li>Luciano Vernaschi (Italian)</li>
<li>Ivan Vucica and Davor Cihlar (Croatian)</li>
<li>Garito (Spanish)</li>
<li>Gabriel Schwardy (Slovak)</li>
<li>Olivier (Esperento)</li>
<li>Janne Mäntyharju (Finnish)</li>
<li>Abentian (Simplified chinese)</li>
<li>Valentin Hristov (Bulgarian)</li>
</ul>
</li>
<li>Syntax definitions
@ -52,7 +56,8 @@
<li>Pavle Ggardijan (Robots.txt)</li>
<li>Miladin Joksic (T-SQL)</li>
<li>Christoph Pinkel (Perl)</li>
<li>Max Leynov (Coldfusion)</li>
<li>Max Leynov (Coldfusion)</li>
<li>Dawson Goodel (Java)</li>
</ul>
</li>
<li>Donation
@ -64,7 +69,7 @@
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -58,7 +58,7 @@ test_but: "test button"
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -168,7 +168,7 @@ editArea.add_plugin("<span class='marked'>test</span>", EditArea_<span class='ma
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -132,7 +132,7 @@
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -152,7 +152,7 @@
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -29,12 +29,12 @@
</li>
<li><a href='compatibility.html'>Compatibility chart</a></li>
<li><a href='credits.html'>Credits</a></li>
<li><a href='license.html'>License</a></li>
<li><a href='license.html'>Licenses</a></li>
</ul>
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -96,14 +96,12 @@ body, html{
Here is an example of EditArea possibilities: <a href="../exemples/exemple_full.html">Full exemple</a>.
</p>
<p>
If you have any problems, you could contact me on
<a href='http://www.cdolivet.net/index.php?page=Contact'>my website</a>.
Just be sure you've read the documentation before...
</p>
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

File diff suppressed because one or more lines are too long

View file

@ -7,477 +7,41 @@
<link href="doc_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='header'>
<h1>EditArea licenses</h1>
</div>
<div class='content'>
<p>
EditArea is released under "LGPL", "Apache" and "BSD" licenses, which mean that you can use EditArea if you follow at least one of thoses licenses.
</p>
</div>
<div class='header'>
<h1>EditArea license (LGPL)</h1>
<h1>LGPL</h1>
</div>
<div class='content'>
<p>
Visit <a href='http://www.fsf.org'>http://www.fsf.org</a> for more information about Open-Source licenses.
</p>
<pre>
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. 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 not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the 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
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
</pre>
Visit <a href='http://www.gnu.org/copyleft/lesser.html'>http://www.gnu.org/copyleft/lesser.html</a> for more information about LGPL license.
</p>
</div>
<div class='header'>
<h1>BSD</h1>
</div>
<div class='content'>
<p>
Visit <a href='http://www.opensource.org/licenses/bsd-license.php'>http://www.opensource.org/licenses/bsd-license.php</a> for more information about BSD license.
</p>
</div>
<div class='header'>
<h1>APACHE</h1>
</div>
<div class='content'>
<p>
Visit <a href='http://www.apache.org/licenses/LICENSE-2.0'>http://www.apache.org/licenses/LICENSE-2.0</a> for more information about Apache license.
</p>
</div>
<div class='footer'>
<div class="indexlink"><a href="index.html">Index</a></div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet - 2007</div>
<div class='copyright'>EditArea - &copy; Christophe Dolivet 2007-2008</div>
<br style="clear: both" />
</div>
</body>

View file

@ -74,8 +74,8 @@ var EditArea_autocompletion= {
editArea.container.insertBefore( this.container, editArea.container.firstChild );
// add event detection for hiding suggestion box
editArea.add_event( document, "click", function(){ editArea.plugins['autocompletion']._hide();} );
editArea.add_event( editArea.textarea, "blur", function(){ editArea.plugins['autocompletion']._hide();} );
parent.editAreaLoader.add_event( document, "click", function(){ editArea.plugins['autocompletion']._hide();} );
parent.editAreaLoader.add_event( editArea.textarea, "blur", function(){ editArea.plugins['autocompletion']._hide();} );
}
@ -140,7 +140,7 @@ var EditArea_autocompletion= {
// show current suggestion list and do autoSelect if possible (no matter it's shown or hidden)
if( letter=="Space" && CtrlPressed(e) )
{
parent.console.log('SHOW SUGGEST');
//parent.console.log('SHOW SUGGEST');
this.forceDisplay = true;
this.autoSelectIfOneResult = true;
this._checkLetter();
@ -251,8 +251,7 @@ var EditArea_autocompletion= {
{
cursor_forced_position = content.indexOf( '{@}' );
content = content.replace(/{@}/g, '' );
if(editArea.nav['isIE'])
editArea.getIESelection();
editArea.getIESelection();
// retrive the number of matching characters
var start_index = Math.max( 0, editArea.textarea.selectionEnd - content.length );
@ -308,7 +307,7 @@ var EditArea_autocompletion= {
tmp["match_word"]= new RegExp("(?:"+ datas["REGEXP"]["before_word"] +")("+ datas["REGEXP"]["possible_words_letters"] +")$", tmp["modifiers"]);
tmp["match_next_letter"]= new RegExp("^("+ datas["REGEXP"]["letter_after_word_must_match"] +")$", tmp["modifiers"]);
tmp["keywords"]= {};
console.log( datas["KEYWORDS"] );
//console.log( datas["KEYWORDS"] );
for( var prefix in datas["KEYWORDS"] )
{
tmp["keywords"][prefix]= {
@ -352,19 +351,18 @@ var EditArea_autocompletion= {
this._parseSyntaxAutoCompletionDatas();
this.curr_syntax= parent.editAreaLoader.syntax[editArea.settings['syntax']]['autocompletion'];
this.curr_syntax_str = editArea.settings['syntax'];
console.log( this.curr_syntax );
//console.log( this.curr_syntax );
}
if( editArea.is_editable )
{
time=new Date;
t1= time.getTime();
if(editArea.nav['isIE'])
editArea.getIESelection();
editArea.getIESelection();
this.selectIndex = -1;
start=editArea.textarea.selectionStart;
var str = editArea.textarea.value;
var results= new Array();
var results= [];
for(var i in this.curr_syntax)
@ -385,7 +383,7 @@ var EditArea_autocompletion= {
{
var begin_word= match_word[1];
var match_curr_word= new RegExp("^"+ parent.editAreaLoader.get_escaped_regexp( begin_word ), this.curr_syntax[i]["modifiers"]);
console.log( match_curr_word );
//console.log( match_curr_word );
for(var prefix in this.curr_syntax[i]["keywords"])
{
// parent.console.log( this.curr_syntax[i]["keywords"][prefix] );
@ -451,7 +449,7 @@ var EditArea_autocompletion= {
// there is only one result, and we can select it automatically
if( results.length == 1 && this.autoSelectIfOneResult )
{
console.log( results );
// console.log( results );
this._select( results[0][1]['replace_with'] );
}
else if( results.length == 0 )
@ -473,7 +471,7 @@ var EditArea_autocompletion= {
// sort results
this.container.innerHTML = '<ul>'+ lines.sort().join('') +'</ul>';
var cursor = $("cursor_pos");
var cursor = _$("cursor_pos");
this.container.style.top = ( cursor.cursor_top + editArea.lineHeight ) +"px";
this.container.style.left = ( cursor.cursor_left + 8 ) +"px";
this._show();

View file

@ -13,7 +13,7 @@ body, html, table, form, textarea{
#editor{
border: solid #888 1px;
overflow: visible;
overflow: hidden;
}
#result{
@ -51,6 +51,7 @@ body, html, table, form, textarea{
z-index: 7;
border-width: 0;
background-color: transparent;
resize: none;
}
#textarea, #textarea:hover{
@ -67,10 +68,10 @@ body, html, table, form, textarea{
}
#selection_field{
#selection_field, #selection_field_text{
margin: 0;
background-color: #E1F2F9;
height: 1px;
/* height: 1px; */
position: absolute;
z-index: 5;
top: -100px;
@ -79,13 +80,35 @@ body, html, table, form, textarea{
overflow: hidden;
}
#selection_field.show_colors{
#selection_field.show_colors {
z-index: 3;
background-color:#EDF9FC;
color:transparent;
}
#container.wrap_text #content_highlight, #container.wrap_text #selection_field{
#selection_field strong{
font-weight:normal;
}
#selection_field.show_colors *, #selection_field_text * {
visibility: hidden;
}
#selection_field_text{
background-color:transparent;
}
#selection_field_text strong{
font-weight:normal;
background-color:#3399FE;
color: #FFF;
visibility:visible;
}
#container.word_wrap #content_highlight,
#container.word_wrap #selection_field,
#container.word_wrap #selection_field_text,
#container.word_wrap #test_font_size{
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
@ -129,7 +152,7 @@ pre{
z-index:6;
background-color: #FF6633;
top: -100px;
margin: 1px 0 0 0;
margin: 0;
}
#result .edit_area_selection_field .overline{

View file

@ -2,168 +2,139 @@
*
* EditArea
* Developped by Christophe Dolivet
* Released under LGPL and Apache licenses
* Released under LGPL, Apache and BSD licenses (use the one you want)
*
******/
function EditArea(){
this.error= false; // to know if load is interrrupt
var t=this;
t.error= false; // to know if load is interrrupt
this.inlinePopup= new Array({popup_id: "area_search_replace", icon_id: "search"},
{popup_id: "edit_area_help", icon_id: "help"});
this.plugins= new Object();
t.inlinePopup= [{popup_id: "area_search_replace", icon_id: "search"},
{popup_id: "edit_area_help", icon_id: "help"}];
t.plugins= {};
this.line_number=0;
t.line_number=0;
this.nav=parent.editAreaLoader.nav; // navigator identification
parent.editAreaLoader.set_browser_infos(t); // navigator identification
// fix IE8 detection as we run in IE7 emulate mode through X-UA <meta> tag
if( t.isIE >= 8 )
t.isIE = 7;
this.last_selection=new Object();
this.last_text_to_highlight="";
this.last_hightlighted_text= "";
this.syntax_list= new Array();
this.allready_used_syntax= new Object();
this.check_line_selection_timer= 50; // the timer delay for modification and/or selection change detection
t.last_selection={};
t.last_text_to_highlight="";
t.last_hightlighted_text= "";
t.syntax_list= [];
t.allready_used_syntax= {};
t.check_line_selection_timer= 50; // the timer delay for modification and/or selection change detection
this.textareaFocused= false;
this.highlight_selection_line= null;
this.previous= new Array();
this.next= new Array();
this.last_undo="";
this.files= new Object();
this.filesIdAssoc= new Object();
this.curr_file= '';
//this.loaded= false;
this.assocBracket=new Object();
this.revertAssocBracket= new Object();
t.textareaFocused= false;
t.highlight_selection_line= null;
t.previous= [];
t.next= [];
t.last_undo="";
t.files= {};
t.filesIdAssoc= {};
t.curr_file= '';
//t.loaded= false;
t.assocBracket={};
t.revertAssocBracket= {};
// bracket selection init
this.assocBracket["("]=")";
this.assocBracket["{"]="}";
this.assocBracket["["]="]";
for(var index in this.assocBracket){
this.revertAssocBracket[this.assocBracket[index]]=index;
t.assocBracket["("]=")";
t.assocBracket["{"]="}";
t.assocBracket["["]="]";
for(var index in t.assocBracket){
t.revertAssocBracket[t.assocBracket[index]]=index;
}
this.is_editable= true;
t.is_editable= true;
/*this.textarea="";
/*t.textarea="";
this.state="declare";
this.code = new Array(); // store highlight syntax for languagues*/
t.state="declare";
t.code = []; // store highlight syntax for languagues*/
// font datas
this.lineHeight= 16;
/*this.default_font_family= "monospace";
this.default_font_size= 10;*/
this.tab_nb_char= 8; //nb of white spaces corresponding to a tabulation
if(this.nav['isOpera'])
this.tab_nb_char= 6;
t.lineHeight= 16;
/*t.default_font_family= "monospace";
t.default_font_size= 10;*/
t.tab_nb_char= 8; //nb of white spaces corresponding to a tabulation
if(t.isOpera)
t.tab_nb_char= 6;
this.is_tabbing= false;
t.is_tabbing= false;
this.fullscreen= {'isFull': false};
t.fullscreen= {'isFull': false};
this.isResizing=false; // resize var
t.isResizing=false; // resize var
// init with settings and ID
this.id= area_id;
this.settings= editAreas[this.id]["settings"];
// init with settings and ID (area_id is a global var defined by editAreaLoader on iframe creation
t.id= area_id;
t.settings= editAreas[t.id]["settings"];
if((""+this.settings['replace_tab_by_spaces']).match(/^[0-9]+$/))
if((""+t.settings['replace_tab_by_spaces']).match(/^[0-9]+$/))
{
this.tab_nb_char= this.settings['replace_tab_by_spaces'];
this.tabulation="";
for(var i=0; i<this.tab_nb_char; i++)
this.tabulation+=" ";
t.tab_nb_char= t.settings['replace_tab_by_spaces'];
t.tabulation="";
for(var i=0; i<t.tab_nb_char; i++)
t.tabulation+=" ";
}else{
this.tabulation="\t";
t.tabulation="\t";
}
// retrieve the init parameter for syntax
if(this.settings["syntax_selection_allow"] && this.settings["syntax_selection_allow"].length>0)
this.syntax_list= this.settings["syntax_selection_allow"].replace(/ /g,"").split(",");
if(t.settings["syntax_selection_allow"] && t.settings["syntax_selection_allow"].length>0)
t.syntax_list= t.settings["syntax_selection_allow"].replace(/ /g,"").split(",");
if(this.settings['syntax'])
this.allready_used_syntax[this.settings['syntax']]=true;
if(t.settings['syntax'])
t.allready_used_syntax[t.settings['syntax']]=true;
};
//called by the toggle_on
EditArea.prototype.update_size= function(){
if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]==true){
if(editArea.fullscreen['isFull']){
parent.document.getElementById("frame_"+editArea.id).style.width= parent.document.getElementsByTagName("html")[0].clientWidth + "px";
parent.document.getElementById("frame_"+editArea.id).style.height= parent.document.getElementsByTagName("html")[0].clientHeight + "px";
}
if(editArea.tab_browsing_area.style.display=='block' && !editArea.nav['isIE'])
{
editArea.tab_browsing_area.style.height= "0px";
editArea.tab_browsing_area.style.height= (editArea.result.offsetTop - editArea.tab_browsing_area.offsetTop -1)+"px";
}
var height= document.body.offsetHeight - editArea.get_all_toolbar_height() - 4;
editArea.result.style.height= height +"px";
var width=document.body.offsetWidth -2;
editArea.result.style.width= width+"px";
//alert("result h: "+ height+" w: "+width+"\ntoolbar h: "+this.get_all_toolbar_height()+"\nbody_h: "+document.body.offsetHeight);
// check that the popups don't get out of the screen
for(var i=0; i<editArea.inlinePopup.length; i++){
var popup= $(editArea.inlinePopup[i]["popup_id"]);
var max_left= document.body.offsetWidth- popup.offsetWidth;
var max_top= document.body.offsetHeight- popup.offsetHeight;
if(popup.offsetTop>max_top)
popup.style.top= max_top+"px";
if(popup.offsetLeft>max_left)
popup.style.left= max_left+"px";
}
}
};
EditArea.prototype.init= function(){
this.textarea= $("textarea");
this.container= $("container");
this.result= $("result");
this.content_highlight= $("content_highlight");
this.selection_field= $("selection_field");
this.processing_screen= $("processing");
this.editor_area= $("editor");
this.tab_browsing_area= $("tab_browsing_area");
var t=this, a, s=t.settings;
t.textarea = _$("textarea");
t.container = _$("container");
t.result = _$("result");
t.content_highlight = _$("content_highlight");
t.selection_field = _$("selection_field");
t.selection_field_text= _$("selection_field_text");
t.processing_screen = _$("processing");
t.editor_area = _$("editor");
t.tab_browsing_area = _$("tab_browsing_area");
t.test_font_size = _$("test_font_size");
a = t.textarea;
if(!this.settings['is_editable'])
this.set_editable(false);
if(!s['is_editable'])
t.set_editable(false);
this.set_show_line_colors( this.settings['show_line_colors'] );
t.set_show_line_colors( s['show_line_colors'] );
if(syntax_selec= $("syntax_selection"))
if(syntax_selec= _$("syntax_selection"))
{
// set up syntax selection lsit in the toolbar
for(var i=0; i<this.syntax_list.length; i++) {
var syntax= this.syntax_list[i];
for(var i=0; i<t.syntax_list.length; i++) {
var syntax= t.syntax_list[i];
var option= document.createElement("option");
option.value= syntax;
if(syntax==this.settings['syntax'])
if(syntax==s['syntax'])
option.selected= "selected";
option.innerHTML= this.get_translation("syntax_" + syntax, "word");
option.innerHTML= t.get_translation("syntax_" + syntax, "word");
syntax_selec.appendChild(option);
}
}
// add plugins buttons in the toolbar
spans= parent.getChildren($("toolbar_1"), "span", "", "", "all", -1);
spans= parent.getChildren(_$("toolbar_1"), "span", "", "", "all", -1);
for(var i=0; i<spans.length; i++){
id=spans[i].id.replace(/tmp_tool_(.*)/, "$1");
if(id!= spans[i].id){
for(var j in this.plugins){
if(typeof(this.plugins[j].get_control_html)=="function" ){
html=this.plugins[j].get_control_html(id);
for(var j in t.plugins){
if(typeof(t.plugins[j].get_control_html)=="function" ){
html=t.plugins[j].get_control_html(id);
if(html!=false){
html= this.get_translation(html, "template");
html= t.get_translation(html, "template");
var new_span= document.createElement("span");
new_span.innerHTML= html;
var father= spans[i].parentNode;
@ -175,55 +146,58 @@
}
}
// init datas
this.textarea.value=editAreas[this.id]["textarea"].value;
if(this.settings["debug"])
this.debug=parent.document.getElementById("edit_area_debug_"+this.id);
//a.value = 'a';//editAreas[t.id]["textarea"].value;
if(s["debug"])
{
t.debug=parent.document.getElementById("edit_area_debug_"+t.id);
}
// init size
//this.update_size();
if($("redo") != null)
this.switchClassSticky($("redo"), 'editAreaButtonDisabled', true);
if(_$("redo") != null)
t.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true);
// insert css rules for highlight mode
if(typeof(parent.editAreaLoader.syntax[this.settings["syntax"]])!="undefined"){
if(typeof(parent.editAreaLoader.syntax[s["syntax"]])!="undefined"){
for(var i in parent.editAreaLoader.syntax){
this.add_style(parent.editAreaLoader.syntax[i]["styles"]);
if (typeof(parent.editAreaLoader.syntax[i]["styles"]) != "undefined"){
t.add_style(parent.editAreaLoader.syntax[i]["styles"]);
}
}
}
// init key events
if(this.nav['isOpera'])
$("editor").onkeypress= keyDown;
if(t.isOpera)
_$("editor").onkeypress = keyDown;
else
$("editor").onkeydown= keyDown;
_$("editor").onkeydown = keyDown;
for(var i=0; i<this.inlinePopup.length; i++){
if(this.nav['isIE'] || this.nav['isFirefox'])
$(this.inlinePopup[i]["popup_id"]).onkeydown= keyDown;
for(var i=0; i<t.inlinePopup.length; i++){
if(t.isOpera)
_$(t.inlinePopup[i]["popup_id"]).onkeypress = keyDown;
else
$(this.inlinePopup[i]["popup_id"]).onkeypress= keyDown;
_$(t.inlinePopup[i]["popup_id"]).onkeydown = keyDown;
}
if(this.settings["allow_resize"]=="both" || this.settings["allow_resize"]=="x" || this.settings["allow_resize"]=="y")
this.allow_resize(true);
if(s["allow_resize"]=="both" || s["allow_resize"]=="x" || s["allow_resize"]=="y")
t.allow_resize(true);
parent.editAreaLoader.toggle(this.id, "on");
//this.textarea.focus();
parent.editAreaLoader.toggle(t.id, "on");
//a.focus();
// line selection init
this.change_smooth_selection_mode(editArea.smooth_selection);
t.change_smooth_selection_mode(editArea.smooth_selection);
// highlight
this.execCommand("change_highlight", this.settings["start_highlight"]);
t.execCommand("change_highlight", s["start_highlight"]);
// get font size datas
this.set_font(editArea.settings["font_family"], editArea.settings["font_size"]);
t.set_font(editArea.settings["font_family"], editArea.settings["font_size"]);
// set unselectable text
children= parent.getChildren(document.body, "", "selec", "none", "all", -1);
for(var i=0; i<children.length; i++){
if(this.nav['isIE'])
if(t.isIE)
children[i].unselectable = true; // IE
else
children[i].onmousedown= function(){return false};
@ -231,61 +205,67 @@
children[i].style.KhtmlUserSelect = "none"; // Konqueror/Safari*/
}
if(this.nav['isGecko']){
this.textarea.spellcheck= this.settings["gecko_spellcheck"];
}
a.spellcheck= s["gecko_spellcheck"];
/** Browser specific style fixes **/
// fix rendering bug for highlighted lines beginning with no tabs
if( this.nav['isFirefox'] >= '3' )
this.content_highlight.style.borderLeft= "solid 1px transparent";
if( t.isFirefox >= '3' ) {
t.content_highlight.style.paddingLeft= "1px";
t.selection_field.style.paddingLeft= "1px";
t.selection_field_text.style.paddingLeft= "1px";
}
if(this.nav['isIE']){
this.textarea.style.marginTop= "-1px";
if(t.isIE && t.isIE < 8 ){
a.style.marginTop= "-1px";
}
/*
if(this.nav['isOpera']){
this.editor_area.style.position= "absolute";
if(t.isOpera){
t.editor_area.style.position= "absolute";
}*/
if(this.nav['isSafari'] ){
this.editor_area.style.position= "absolute";
this.textarea.style.marginLeft="-3px";
this.textarea.style.marginTop="1px";
}
if( this.nav['isChrome'] ){
this.editor_area.style.position= "absolute";
this.textarea.style.marginLeft="0px";
this.textarea.style.marginTop="0px";
if( t.isSafari ){
t.editor_area.style.position = "absolute";
a.style.marginLeft ="-3px";
if( t.isSafari < 3.2 ) // Safari 3.0 (3.1?)
a.style.marginTop ="1px";
}
// si le textarea n'est pas grand, un click sous le textarea doit provoquer un focus sur le textarea
parent.editAreaLoader.add_event(this.result, "click", function(e){ if((e.target || e.srcElement)==editArea.result) { editArea.area_select(editArea.textarea.value.length, 0);} });
parent.editAreaLoader.add_event(t.result, "click", function(e){ if((e.target || e.srcElement)==editArea.result) { editArea.area_select(editArea.textarea.value.length, 0);} });
if(this.settings['is_multi_files']!=false)
this.open_file({'id': this.curr_file, 'text': ''});
if(s['is_multi_files']!=false)
t.open_file({'id': t.curr_file, 'text': ''});
this.set_wrap_text( this.settings['wrap_text'] );
t.set_word_wrap( s['word_wrap'] );
setTimeout("editArea.focus();editArea.manage_size();editArea.execCommand('EA_load');", 10);
//start checkup routine
this.check_undo();
this.check_line_selection(true);
this.scroll_to_view();
t.check_undo();
t.check_line_selection(true);
t.scroll_to_view();
for(var i in this.plugins){
if(typeof(this.plugins[i].onload)=="function")
this.plugins[i].onload();
for(var i in t.plugins){
if(typeof(t.plugins[i].onload)=="function")
t.plugins[i].onload();
}
if(this.settings['fullscreen']==true)
this.toggle_full_screen(true);
if(s['fullscreen']==true)
t.toggle_full_screen(true);
parent.editAreaLoader.add_event(window, "resize", editArea.update_size);
parent.editAreaLoader.add_event(parent.window, "resize", editArea.update_size);
parent.editAreaLoader.add_event(top.window, "resize", editArea.update_size);
parent.editAreaLoader.add_event(window, "unload", function(){if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]) editArea.execCommand("EA_unload");});
parent.editAreaLoader.add_event(window, "unload", function(){
// in case where editAreaLoader have been already cleaned
if( parent.editAreaLoader )
{
parent.editAreaLoader.remove_event(parent.window, "resize", editArea.update_size);
parent.editAreaLoader.remove_event(top.window, "resize", editArea.update_size);
}
if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]){
editArea.execCommand("EA_unload");
}
});
/*date= new Date();
@ -293,50 +273,94 @@
};
//called by the toggle_on
EditArea.prototype.update_size= function(){
var d=document,pd=parent.document,height,width,popup,maxLeft,maxTop;
if( typeof editAreas != 'undefined' && editAreas[editArea.id] && editAreas[editArea.id]["displayed"]==true){
if(editArea.fullscreen['isFull']){
pd.getElementById("frame_"+editArea.id).style.width = pd.getElementsByTagName("html")[0].clientWidth + "px";
pd.getElementById("frame_"+editArea.id).style.height = pd.getElementsByTagName("html")[0].clientHeight + "px";
}
if(editArea.tab_browsing_area.style.display=='block' && ( !editArea.isIE || editArea.isIE >= 8 ) )
{
editArea.tab_browsing_area.style.height = "0px";
editArea.tab_browsing_area.style.height = (editArea.result.offsetTop - editArea.tab_browsing_area.offsetTop -1)+"px";
}
height = d.body.offsetHeight - editArea.get_all_toolbar_height() - 4;
editArea.result.style.height = height +"px";
width = d.body.offsetWidth -2;
editArea.result.style.width = width+"px";
//alert("result h: "+ height+" w: "+width+"\ntoolbar h: "+this.get_all_toolbar_height()+"\nbody_h: "+document.body.offsetHeight);
// check that the popups don't get out of the screen
for( i=0; i < editArea.inlinePopup.length; i++ )
{
popup = _$(editArea.inlinePopup[i]["popup_id"]);
maxLeft = d.body.offsetWidth - popup.offsetWidth;
maxTop = d.body.offsetHeight - popup.offsetHeight;
if( popup.offsetTop > maxTop )
popup.style.top = maxTop+"px";
if( popup.offsetLeft > maxLeft )
popup.style.left = maxLeft+"px";
}
editArea.manage_size( true );
editArea.fixLinesHeight( editArea.textarea.value, 0,-1);
}
};
EditArea.prototype.manage_size= function(onlyOneTime){
if(!editAreas[this.id])
return false;
if(editAreas[this.id]["displayed"]==true && this.textareaFocused)
{
var resized= false;
var area_height,resized= false;
//1) Manage display width
//1.1) Calc the new width to use for display
if( this.settings['wrap_text'] )
{
// var area_width= this.result.offsetWidth -50;
}
else
if( !this.settings['word_wrap'] )
{
var area_width= this.textarea.scrollWidth;
var area_height= this.textarea.scrollHeight;
if(this.nav['isOpera']){
area_width=10000; /* TODO: find a better way to fix the width problem */
area_height= this.textarea.scrollHeight;
// bug on old opera versions
if(this.isOpera && this.isOpera < 9.6 ){
area_width=10000;
}
//1.2) the width is not the same, we must resize elements
if(this.textarea.previous_scrollWidth!=area_width)
{
this.container.style.width= area_width+"px";
this.textarea.style.width= area_width+"px";
this.content_highlight.style.width= area_width+"px";
this.textarea.previous_scrollWidth=area_width;
resized=true;
}
}
//1.2) the width is not the same, we must resize elements
if(this.textarea.previous_scrollWidth!=area_width)
{
this.container.style.width= area_width+"px";
this.textarea.style.width= area_width+"px";
this.content_highlight.style.width= area_width+"px";
this.textarea.previous_scrollWidth=area_width;
resized=true;
}
// manage wrap width
if( this.settings['word_wrap'] )
{
newW=this.textarea.offsetWidth;
if( this.isFirefox || this.isIE )
newW-=2;
if( this.isSafari )
newW-=6;
this.content_highlight.style.width=this.selection_field_text.style.width=this.selection_field.style.width=this.test_font_size.style.width=newW+"px";
}
//2) Manage display height
//2.1) Calc the new height to use for display
var area_height = this.textarea.scrollHeight;
if(this.nav['isOpera']){
area_height= this.last_selection['nb_line']*this.lineHeight;
}
if(this.nav['isGecko'] && this.smooth_selection && this.last_selection["nb_line"])
area_height= this.last_selection["nb_line"]*this.lineHeight;
if( this.isOpera || this.isFirefox || this.isSafari ) {
area_height= this.getLinePosTop( this.last_selection["nb_line"] + 1 );
} else {
area_height = this.textarea.scrollHeight;
}
//2.2) the width is not the same, we must resize elements
if(this.textarea.previous_scrollHeight!=area_height)
{
@ -350,17 +374,15 @@
//3) if there is new lines, we add new line numbers in the line numeration area
if(this.last_selection["nb_line"] >= this.line_number)
{
var div_line_number="";
for(i=this.line_number+1; i<this.last_selection["nb_line"]+100; i++)
var newLines= '', destDiv=_$("line_number"), start=this.line_number, end=this.last_selection["nb_line"]+100;
for( i = start+1; i < end; i++ )
{
div_line_number+=i+"<br />";
newLines+='<div id="line_'+ i +'">'+i+"</div>";
this.line_number++;
}
var span= document.createElement("span");
if(this.nav['isIE'])
span.unselectable=true;
span.innerHTML=div_line_number;
$("line_number").appendChild(span);
destDiv.innerHTML= destDiv.innerHTML + newLines;
this.fixLinesHeight( this.textarea.value, start, -1 );
}
//4) be sure the text is well displayed
@ -370,18 +392,11 @@
this.scroll_to_view();
}
}
if(!onlyOneTime)
setTimeout("editArea.manage_size();", 100);
};
EditArea.prototype.add_event = function(obj, name, handler) {
if (this.nav['isIE']) {
obj.attachEvent("on" + name, handler);
} else{
obj.addEventListener(name, handler, false);
}
};
EditArea.prototype.execCommand= function(cmd, param){
for(var i in this.plugins){
@ -494,16 +509,16 @@
// add plugin translation to language translation array
EditArea.prototype.add_lang= function(language, values){
if(!parent.editAreaLoader.lang[language])
parent.editAreaLoader.lang[language]=new Object();
parent.editAreaLoader.lang[language]={};
for(var i in values)
parent.editAreaLoader.lang[language][i]= values[i];
};
// short cut for document.getElementById()
function $(id){return document.getElementById( id );};
function _$(id){return document.getElementById( id );};
var editArea = new EditArea();
editArea.add_event(window, "load", init);
parent.editAreaLoader.add_event(window, "load", init);
function init(){
setTimeout("editArea.init(); ", 10);

View file

@ -3,7 +3,7 @@
*
* EditArea PHP compressor
* Developped by Christophe Dolivet
* Released under LGPL and Apache licenses
* Released under LGPL, Apache and BSD licenses
* v1.1.3 (2007/01/18)
*
******/
@ -143,11 +143,11 @@
$loader= $this->get_content("edit_area_loader.js")."\n";
// get the list of other files to load
$loader= preg_replace("/(this\.scripts_to_load= new Array)\(([^\)]*)\);/e"
$loader= preg_replace("/(t\.scripts_to_load=\s*)\[([^\]]*)\];/e"
, "\$this->replace_scripts('script_list', '\\1', '\\2')"
, $loader);
$loader= preg_replace("/(this\.sub_scripts_to_load= new Array)\(([^\)]*)\);/e"
$loader= preg_replace("/(t\.sub_scripts_to_load=\s*)\[([^\]]*)\];/e"
, "\$this->replace_scripts('sub_script_list', '\\1', '\\2')"
, $loader);
@ -332,7 +332,7 @@
// add line break before "else" otherwise navigators can't manage to parse the file
$code= preg_replace('/(\b(else)\b)/', "\n$1", $code);
// remove unnecessary spaces
$code= preg_replace('/( |\t|\r)?(;|\{|\}|=|==|\-|\+|,|\(|\)|\|\||&\&|\:)( |\t|\r)+/', "$2", $code);
$code= preg_replace('/( |\t|\r)*(;|\{|\}|=|==|\-|\+|,|\(|\)|\|\||&\&|\:)( |\t|\r)*/', "$2", $code);
}
}
@ -372,7 +372,7 @@
function replace_scripts($var, $param1, $param2)
{
$this->$var=stripslashes($param2);
return $param1."();";
return $param1."[];";
}
/* for php version that have not thoses functions */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,22 +5,22 @@
// need to redefine this functiondue to IE problem
function getAttribute( elm, aname ) {
function getAttribute( elm, aName ) {
var aValue,taName,i;
try{
var avalue = elm.getAttribute( aname );
}catch(exept){
aValue = elm.getAttribute( aName );
}catch(exept){}
}
if ( ! avalue ) {
for ( var i = 0; i < elm.attributes.length; i ++ ) {
var taName = elm.attributes [i] .name.toLowerCase();
if ( taName == aname ) {
avalue = elm.attributes [i] .value;
return avalue;
if( ! aValue ){
for( i = 0; i < elm.attributes.length; i ++ ) {
taName = elm.attributes[i] .name.toLowerCase();
if( taName == aName ) {
aValue = elm.attributes[i] .value;
return aValue;
}
}
}
return avalue;
return aValue;
};
// need to redefine this function due to IE problem
@ -50,7 +50,7 @@
if(elem){
var children= elem.childNodes;
var result=null;
var results= new Array();
var results= [];
for (var x=0;x<children.length;x++) {
strTagName = new String(children[x].tagName);
children_class="?";
@ -93,46 +93,37 @@
};
function getMouseX(e){
/*if(document.all)
return event.x + document.body.scrollLeft;
else
return e.pageX;*/
if(e!=null && typeof(e.pageX)!="undefined"){
return e.pageX;
}else{
return (e!=null?e.x:event.x)+ document.documentElement.scrollLeft;
}
//return (e!=null) ? e.pageX : event.x + document.documentElement.scrollLeft;
};
function getMouseY(e){
/*if(document.all)
return event.y + document.body.scrollTop;
else
return e.pageY;*/
if(e!=null && typeof(e.pageY)!="undefined"){
return e.pageY;
}else{
return (e!=null?e.y:event.y)+ document.documentElement.scrollTop;
}
//return (e!=null) ? e.pageY : event.y + document.documentElement.scrollTop;
};
function calculeOffsetLeft(r){
return calculeOffset(r,"offsetLeft")
return calculeOffset(r,"offsetLeft")
};
function calculeOffsetTop(r){
return calculeOffset(r,"offsetTop")
return calculeOffset(r,"offsetTop")
};
function calculeOffset(element,attr){
var offset=0;
while(element){
offset+=element[attr];
element=element.offsetParent
}
return offset;
var offset=0;
while(element){
offset+=element[attr];
element=element.offsetParent
}
return offset;
};
/** return the computed style
@ -160,7 +151,8 @@
* Moving an element
***/
var move_current_element;
var _mCE; // currently moving element
/* allow to move an element in a window
e: the event
id: the id of the element
@ -179,46 +171,44 @@
if(frame.event)
e=frame.event;
move_current_element= frame.document.getElementById(elem_id);
move_current_element.frame=frame;
_mCE= frame.document.getElementById(elem_id);
_mCE.frame=frame;
frame.document.onmousemove= move_element;
frame.document.onmouseup= end_move_element;
/*move_current_element.onmousemove= move_element;
move_current_element.onmouseup= end_move_element;*/
/*_mCE.onmousemove= move_element;
_mCE.onmouseup= end_move_element;*/
//alert(move_current_element.frame.document.body.offsetHeight);
//alert(_mCE.frame.document.body.offsetHeight);
mouse_x= getMouseX(e);
mouse_y= getMouseY(e);
//window.status=frame+ " elem: "+elem_id+" elem: "+ move_current_element + " mouse_x: "+mouse_x;
move_current_element.start_pos_x = mouse_x - (move_current_element.style.left.replace("px","") || calculeOffsetLeft(move_current_element));
move_current_element.start_pos_y = mouse_y - (move_current_element.style.top.replace("px","") || calculeOffsetTop(move_current_element));
//window.status=frame+ " elem: "+elem_id+" elem: "+ _mCE + " mouse_x: "+mouse_x;
_mCE.start_pos_x = mouse_x - (_mCE.style.left.replace("px","") || calculeOffsetLeft(_mCE));
_mCE.start_pos_y = mouse_y - (_mCE.style.top.replace("px","") || calculeOffsetTop(_mCE));
return false;
};
function end_move_element(e){
move_current_element.frame.document.onmousemove= "";
move_current_element.frame.document.onmouseup= "";
move_current_element=null;
_mCE.frame.document.onmousemove= "";
_mCE.frame.document.onmouseup= "";
_mCE=null;
};
function move_element(e){
/*window.status="move"+frame;
window.status="move2"+frame.event;*/
if(move_current_element.frame && move_current_element.frame.event)
e=move_current_element.frame.event;
var mouse_x=getMouseX(e);
var mouse_y=getMouseY(e);
var new_top= mouse_y - move_current_element.start_pos_y;
var new_left= mouse_x - move_current_element.start_pos_x;
var newTop,newLeft,maxLeft;
if( _mCE.frame && _mCE.frame.event )
e=_mCE.frame.event;
newTop = getMouseY(e) - _mCE.start_pos_y;
newLeft = getMouseX(e) - _mCE.start_pos_x;
var max_left= move_current_element.frame.document.body.offsetWidth- move_current_element.offsetWidth;
max_top= move_current_element.frame.document.body.offsetHeight- move_current_element.offsetHeight;
new_top= Math.min(Math.max(0, new_top), max_top);
new_left= Math.min(Math.max(0, new_left), max_left);
maxLeft = _mCE.frame.document.body.offsetWidth- _mCE.offsetWidth;
max_top = _mCE.frame.document.body.offsetHeight- _mCE.offsetHeight;
newTop = Math.min(Math.max(0, newTop), max_top);
newLeft = Math.min(Math.max(0, newLeft), maxLeft);
move_current_element.style.top= new_top+"px";
move_current_element.style.left= new_left+"px";
_mCE.style.top = newTop+"px";
_mCE.style.left = newLeft+"px";
return false;
};
@ -230,85 +220,86 @@
// allow to get infos on the selection: array(start, end)
function getSelectionRange(textarea){
//if(nav['isIE'])
// get_IE_selection(textarea);
return {"start": textarea.selectionStart, "end": textarea.selectionEnd};
};
// allow to set the selection
function setSelectionRange(textarea, start, end){
textarea.focus();
function setSelectionRange(t, start, end){
t.focus();
start= Math.max(0, Math.min(textarea.value.length, start));
end= Math.max(start, Math.min(textarea.value.length, end));
start = Math.max(0, Math.min(t.value.length, start));
end = Math.max(start, Math.min(t.value.length, end));
if(nav['isOpera']){ // Opera bug when moving selection start and selection end
textarea.selectionEnd = 1;
textarea.selectionStart = 0;
textarea.selectionEnd = 1;
textarea.selectionStart = 0;
if( this.isOpera && this.isOpera < 9.6 ){ // Opera bug when moving selection start and selection end
t.selectionEnd = 1;
t.selectionStart = 0;
t.selectionEnd = 1;
t.selectionStart = 0;
}
textarea.selectionStart = start;
textarea.selectionEnd = end;
t.selectionStart = start;
t.selectionEnd = end;
//textarea.setSelectionRange(start, end);
if(nav['isIE'])
set_IE_selection(textarea);
if(isIE)
set_IE_selection(t);
};
// set IE position in Firefox mode (textarea.selectionStart and textarea.selectionEnd). should work as a repeated task
function get_IE_selection(textarea){
if(textarea && textarea.focused)
function get_IE_selection(t){
var d=document,div,range,stored_range,elem,scrollTop,relative_top,line_start,line_nb,range_start,range_end,tab;
if(t && t.focused)
{
if(!textarea.ea_line_height)
if(!t.ea_line_height)
{ // calculate the lineHeight
var div= document.createElement("div");
div.style.fontFamily= get_css_property(textarea, "font-family");
div.style.fontSize= get_css_property(textarea, "font-size");
div= d.createElement("div");
div.style.fontFamily= get_css_property(t, "font-family");
div.style.fontSize= get_css_property(t, "font-size");
div.style.visibility= "hidden";
div.innerHTML="0";
document.body.appendChild(div);
textarea.ea_line_height= div.offsetHeight;
document.body.removeChild(div);
d.body.appendChild(div);
t.ea_line_height= div.offsetHeight;
d.body.removeChild(div);
}
//textarea.focus();
var range = document.selection.createRange();
var stored_range = range.duplicate();
stored_range.moveToElementText( textarea );
stored_range.setEndPoint( 'EndToEnd', range );
if(stored_range.parentElement()==textarea){
// the range don't take care of empty lines in the end of the selection
var elem= textarea;
var scrollTop= 0;
while(elem.parentNode){
scrollTop+= elem.scrollTop;
elem= elem.parentNode;
//t.focus();
range = d.selection.createRange();
try
{
stored_range = range.duplicate();
stored_range.moveToElementText( t );
stored_range.setEndPoint( 'EndToEnd', range );
if(stored_range.parentElement() == t){
// the range don't take care of empty lines in the end of the selection
elem = t;
scrollTop = 0;
while(elem.parentNode){
scrollTop+= elem.scrollTop;
elem = elem.parentNode;
}
// var scrollTop= t.scrollTop + document.body.scrollTop;
// var relative_top= range.offsetTop - calculeOffsetTop(t) + scrollTop;
relative_top= range.offsetTop - calculeOffsetTop(t)+ scrollTop;
// alert("rangeoffset: "+ range.offsetTop +"\ncalcoffsetTop: "+ calculeOffsetTop(t) +"\nrelativeTop: "+ relative_top);
line_start = Math.round((relative_top / t.ea_line_height) +1);
line_nb = Math.round(range.boundingHeight / t.ea_line_height);
range_start = stored_range.text.length - range.text.length;
tab = t.value.substr(0, range_start).split("\n");
range_start += (line_start - tab.length)*2; // add missing empty lines to the selection
t.selectionStart = range_start;
range_end = t.selectionStart + range.text.length;
tab = t.value.substr(0, range_start + range.text.length).split("\n");
range_end += (line_start + line_nb - 1 - tab.length)*2;
t.selectionEnd = range_end;
}
// var scrollTop= textarea.scrollTop + document.body.scrollTop;
// var relative_top= range.offsetTop - calculeOffsetTop(textarea) + scrollTop;
var relative_top= range.offsetTop - calculeOffsetTop(textarea)+ scrollTop;
// alert("rangeoffset: "+ range.offsetTop +"\ncalcoffsetTop: "+ calculeOffsetTop(textarea) +"\nrelativeTop: "+ relative_top);
var line_start = Math.round((relative_top / textarea.ea_line_height) +1);
var line_nb= Math.round(range.boundingHeight / textarea.ea_line_height);
// alert("store_range: "+ stored_range.text.length+"\nrange: "+range.text.length+"\nrange_text: "+ range.text);
var range_start= stored_range.text.length - range.text.length;
var tab= textarea.value.substr(0, range_start).split("\n");
range_start+= (line_start - tab.length)*2; // add missing empty lines to the selection
textarea.selectionStart = range_start;
var range_end= textarea.selectionStart + range.text.length;
tab= textarea.value.substr(0, range_start + range.text.length).split("\n");
range_end+= (line_start + line_nb - 1 - tab.length)*2;
textarea.selectionEnd = range_end;
}
catch(e){}
}
setTimeout("get_IE_selection(document.getElementById('"+ textarea.id +"'));", 50);
setTimeout("get_IE_selection(document.getElementById('"+ t.id +"'));", 50);
};
function IE_textarea_focus(){
@ -320,16 +311,21 @@
}
// select the text for IE (take into account the \r difference)
function set_IE_selection(textarea){
function set_IE_selection( t ){
var nbLineStart,nbLineStart,nbLineEnd,range;
if(!window.closed){
var nbLineStart=textarea.value.substr(0, textarea.selectionStart).split("\n").length - 1;
var nbLineEnd=textarea.value.substr(0, textarea.selectionEnd).split("\n").length - 1;
var range = document.selection.createRange();
range.moveToElementText( textarea );
range.setEndPoint( 'EndToStart', range );
range.moveStart('character', textarea.selectionStart - nbLineStart);
range.moveEnd('character', textarea.selectionEnd - nbLineEnd - (textarea.selectionStart - nbLineStart) );
range.select();
nbLineStart=t.value.substr(0, t.selectionStart).split("\n").length - 1;
nbLineEnd=t.value.substr(0, t.selectionEnd).split("\n").length - 1;
try
{
range = document.selection.createRange();
range.moveToElementText( t );
range.setEndPoint( 'EndToStart', range );
range.moveStart('character', t.selectionStart - nbLineStart);
range.moveEnd('character', t.selectionEnd - nbLineEnd - (t.selectionStart - nbLineStart) );
range.select();
}
catch(e){}
}
};

View file

@ -1,8 +1,8 @@
// change_to: "on" or "off"
EditArea.prototype.change_highlight= function(change_to){
if(this.settings["syntax"].length==0 && change_to==false){
this.switchClassSticky($("highlight"), 'editAreaButtonDisabled', true);
this.switchClassSticky($("reset_highlight"), 'editAreaButtonDisabled', true);
this.switchClassSticky(_$("highlight"), 'editAreaButtonDisabled', true);
this.switchClassSticky(_$("reset_highlight"), 'editAreaButtonDisabled', true);
return false;
}
@ -10,8 +10,7 @@
return false;
if(this.nav['isIE'])
this.getIESelection();
this.getIESelection();
var pos_start= this.textarea.selectionStart;
var pos_end= this.textarea.selectionEnd;
@ -22,261 +21,370 @@
this.textarea.focus();
this.textarea.selectionStart = pos_start;
this.textarea.selectionEnd = pos_end;
if(this.nav['isIE'])
this.setIESelection();
this.setIESelection();
};
EditArea.prototype.disable_highlight= function(displayOnly){
this.selection_field.innerHTML="";
this.content_highlight.style.visibility="hidden";
EditArea.prototype.disable_highlight= function(displayOnly){
var t= this, a=t.textarea, new_Obj, old_class, new_class;
t.selection_field.innerHTML="";
t.selection_field_text.innerHTML="";
t.content_highlight.style.visibility="hidden";
// replacing the node is far more faster than deleting it's content in firefox
var new_Obj= this.content_highlight.cloneNode(false);
new_Obj= t.content_highlight.cloneNode(false);
new_Obj.innerHTML= "";
this.content_highlight.parentNode.insertBefore(new_Obj, this.content_highlight);
this.content_highlight.parentNode.removeChild(this.content_highlight);
this.content_highlight= new_Obj;
var old_class= parent.getAttribute(this.textarea,"class");
t.content_highlight.parentNode.insertBefore(new_Obj, t.content_highlight);
t.content_highlight.parentNode.removeChild(t.content_highlight);
t.content_highlight= new_Obj;
old_class= parent.getAttribute( a,"class" );
if(old_class){
var new_class= old_class.replace("hidden","");
parent.setAttribute(this.textarea, "class", new_class);
new_class= old_class.replace( "hidden","" );
parent.setAttribute( a, "class", new_class );
}
this.textarea.style.backgroundColor="transparent"; // needed in order to see the bracket finders
a.style.backgroundColor="transparent"; // needed in order to see the bracket finders
//var icon= document.getElementById("highlight");
//setAttribute(icon, "class", getAttribute(icon, "class").replace(/ selected/g, "") );
//this.restoreClass(icon);
//this.switchClass(icon,'editAreaButtonNormal');
this.switchClassSticky($("highlight"), 'editAreaButtonNormal', true);
this.switchClassSticky($("reset_highlight"), 'editAreaButtonDisabled', true);
//t.restoreClass(icon);
//t.switchClass(icon,'editAreaButtonNormal');
t.switchClassSticky(_$("highlight"), 'editAreaButtonNormal', true);
t.switchClassSticky(_$("reset_highlight"), 'editAreaButtonDisabled', true);
this.do_highlight=false;
t.do_highlight=false;
this.switchClassSticky($("change_smooth_selection"), 'editAreaButtonSelected', true);
if(typeof(this.smooth_selection_before_highlight)!="undefined" && this.smooth_selection_before_highlight===false){
this.change_smooth_selection_mode(false);
t.switchClassSticky(_$("change_smooth_selection"), 'editAreaButtonSelected', true);
if(typeof(t.smooth_selection_before_highlight)!="undefined" && t.smooth_selection_before_highlight===false){
t.change_smooth_selection_mode(false);
}
// this.textarea.style.backgroundColor="#FFFFFF";
};
EditArea.prototype.enable_highlight= function(){
this.show_waiting_screen();
var t=this, a=t.textarea, new_class;
t.show_waiting_screen();
this.content_highlight.style.visibility="visible";
var new_class=parent.getAttribute(this.textarea,"class")+" hidden";
parent.setAttribute(this.textarea, "class", new_class);
t.content_highlight.style.visibility="visible";
new_class =parent.getAttribute(a,"class")+" hidden";
parent.setAttribute( a, "class", new_class );
if(this.nav['isIE'])
this.textarea.style.backgroundColor="#FFFFFF"; // IE can't manage mouse click outside text range without this
// IE can't manage mouse click outside text range without this
if( t.isIE )
a.style.backgroundColor="#FFFFFF";
//var icon= document.getElementById("highlight");
//setAttribute(icon, "class", getAttribute(icon, "class") + " selected");
//this.switchClass(icon,'editAreaButtonSelected');
//this.switchClassSticky($("highlight"), 'editAreaButtonNormal', false);
this.switchClassSticky($("highlight"), 'editAreaButtonSelected', false);
this.switchClassSticky($("reset_highlight"), 'editAreaButtonNormal', false);
t.switchClassSticky(_$("highlight"), 'editAreaButtonSelected', false);
t.switchClassSticky(_$("reset_highlight"), 'editAreaButtonNormal', false);
this.smooth_selection_before_highlight=this.smooth_selection;
if(!this.smooth_selection)
this.change_smooth_selection_mode(true);
this.switchClassSticky($("change_smooth_selection"), 'editAreaButtonDisabled', true);
t.smooth_selection_before_highlight=t.smooth_selection;
if(!t.smooth_selection)
t.change_smooth_selection_mode(true);
t.switchClassSticky(_$("change_smooth_selection"), 'editAreaButtonDisabled', true);
this.do_highlight=true;
this.resync_highlight();
t.do_highlight=true;
t.resync_highlight();
this.hide_waiting_screen();
//area.onkeyup="";
/*if(!displayOnly){
this.do_highlight=true;
this.reSync();
if(this.state=="loaded")
this.textarea.focus();
}*/
t.hide_waiting_screen();
};
/**
* Ask to update highlighted text
* @param Array infos - Array of datas returned by EditArea.get_selection_infos()
*/
EditArea.prototype.maj_highlight= function(infos){
if(this.last_highlight_base_text==infos["full_text"] && this.resync_highlight!==true)
// for speed mesure
var debug_opti="",tps_start= new Date().getTime(), tps_middle_opti=new Date().getTime();
var t=this, hightlighted_text, updated_highlight;
var textToHighlight=infos["full_text"], doSyntaxOpti = false, doHtmlOpti = false, stay_begin="", stay_end="", trace_new , trace_last;
if(t.last_text_to_highlight==infos["full_text"] && t.resync_highlight!==true)
return;
//var infos= this.getSelectionInfos();
if(infos["full_text"].indexOf("\r")!=-1)
text_to_highlight= infos["full_text"].replace(/\r/g, "");
else
text_to_highlight= infos["full_text"];
// for optimisation process
var start_line_pb=-1;
var end_line_pb=-1;
var stay_begin="";
var stay_end="";
var debug_opti="";
// for speed mesure
var date= new Date();
var tps_start=date.getTime();
var tps_middle_opti=date.getTime();
// OPTIMISATION: will search to update only changed lines
if(this.reload_highlight===true){
this.reload_highlight=false;
}else if(text_to_highlight.length==0){
text_to_highlight="\n ";
}else{
var base_step=200;
if(t.reload_highlight===true){
t.reload_highlight=false;
}else if(textToHighlight.length==0){
textToHighlight="\n ";
}else{
// get text change datas
changes = t.checkTextEvolution(t.last_text_to_highlight,textToHighlight);
var cpt= 0;
var end= Math.min(text_to_highlight.length, this.last_text_to_highlight.length);
var step= base_step;
// find how many chars are similar at the begin of the text
while(cpt<end && step>=1){
if(this.last_text_to_highlight.substr(cpt, step) == text_to_highlight.substr(cpt, step)){
cpt+= step;
}else{
step= Math.floor(step/2);
}
}
var pos_start_change=cpt;
var line_start_change= text_to_highlight.substr(0, pos_start_change).split("\n").length -1;
cpt_last= this.last_text_to_highlight.length;
cpt= text_to_highlight.length;
step= base_step;
// find how many chars are similar at the end of the text
while(cpt>=0 && cpt_last>=0 && step>=1){
if(this.last_text_to_highlight.substr(cpt_last-step, step) == text_to_highlight.substr(cpt-step, step)){
cpt-= step;
cpt_last-= step;
}else{
step= Math.floor(step/2);
}
}
//cpt_last=Math.max(0, cpt_last);
var pos_new_end_change= cpt;
var pos_last_end_change= cpt_last;
if(pos_new_end_change<=pos_start_change){
if(this.last_text_to_highlight.length < text_to_highlight.length){
pos_new_end_change= pos_start_change + text_to_highlight.length - this.last_text_to_highlight.length;
pos_last_end_change= pos_start_change;
}else{
pos_last_end_change= pos_start_change + this.last_text_to_highlight.length - text_to_highlight.length;
pos_new_end_change= pos_start_change;
}
}
var change_new_text= text_to_highlight.substring(pos_start_change, pos_new_end_change);
var change_last_text= this.last_text_to_highlight.substring(pos_start_change, pos_last_end_change);
var line_new_end_change= text_to_highlight.substr(0, pos_new_end_change).split("\n").length -1;
var line_last_end_change= this.last_text_to_highlight.substr(0, pos_last_end_change).split("\n").length -1;
var change_new_text_line= text_to_highlight.split("\n").slice(line_start_change, line_new_end_change+1).join("\n");
var change_last_text_line= this.last_text_to_highlight.split("\n").slice(line_start_change, line_last_end_change+1).join("\n");
// check if it can only reparse the changed text
var trace_new= this.get_syntax_trace(change_new_text_line);
var trace_last= this.get_syntax_trace(change_last_text_line);
if(trace_new == trace_last){
trace_new = t.get_syntax_trace(changes.newTextLine).replace(/\r/g, '');
trace_last = t.get_syntax_trace(changes.lastTextLine).replace(/\r/g, '');
doSyntaxOpti = ( trace_new == trace_last );
// check if the difference comes only from a new line created
// => we have to remember that the editor can automaticaly add tabulation or space after the new line)
if( !doSyntaxOpti && trace_new == "\n"+trace_last && /^[ \t\s]*\n[ \t\s]*$/.test( changes.newText.replace(/\r/g, '') ) && changes.lastText =="" )
{
doSyntaxOpti = true;
}
// we do the syntax optimisation
if( doSyntaxOpti ){
tps_middle_opti=new Date().getTime();
date= new Date();
tps_middle_opti=date.getTime();
stay_begin= this.last_hightlighted_text.split("\n").slice(0, line_start_change).join("\n");
if(line_start_change>0)
stay_begin= t.last_hightlighted_text.split("\n").slice(0, changes.lineStart).join("\n");
if(changes.lineStart>0)
stay_begin+= "\n";
stay_end= this.last_hightlighted_text.split("\n").slice(line_last_end_change+1).join("\n");
stay_end= t.last_hightlighted_text.split("\n").slice(changes.lineLastEnd+1).join("\n");
if(stay_end.length>0)
stay_end= "\n"+stay_end;
if(stay_begin.length==0 && pos_last_end_change==-1)
change_new_text_line+="\n";
text_to_highlight=change_new_text_line;
// Final check to see that we're not in the middle of span tags
if( stay_begin.split('<span').length != stay_begin.split('</span').length
|| stay_end.split('<span').length != stay_end.split('</span').length )
{
doSyntaxOpti = false;
stay_end = '';
stay_begin = '';
}
else
{
if(stay_begin.length==0 && changes.posLastEnd==-1)
changes.newTextLine+="\n";
textToHighlight=changes.newTextLine;
}
}
if(this.settings["debug"]){
debug_opti= (trace_new == trace_last)?"Optimisation": "No optimisation";
debug_opti+= " start: "+pos_start_change +"("+line_start_change+")";
debug_opti+=" end_new: "+ pos_new_end_change+"("+line_new_end_change+")";
debug_opti+=" end_last: "+ pos_last_end_change+"("+line_last_end_change+")";
debug_opti+="\nchanged_text: "+change_new_text+" => trace: "+trace_new;
debug_opti+="\nchanged_last_text: "+change_last_text+" => trace: "+trace_last;
//debug_opti+= "\nchanged: "+ infos["full_text"].substring(pos_start_change, pos_new_end_change);
debug_opti+= "\nchanged_line: "+change_new_text_line;
debug_opti+= "\nlast_changed_line: "+change_last_text_line;
debug_opti+="\nstay_begin: "+ stay_begin.slice(-200);
debug_opti+="\nstay_end: "+ stay_end;
//debug_opti="start: "+stay_begin_len+ "("+nb_line_start_unchanged+") end: "+ (stay_end_len)+ "("+(splited.length-nb_line_end_unchanged)+") ";
//debug_opti+="changed: "+ text_to_highlight.substring(stay_begin_len, text_to_highlight.length-stay_end_len)+" \n";
//debug_opti+="changed: "+ stay_begin.substr(stay_begin.length-200)+ "----------"+ text_to_highlight+"------------------"+ stay_end.substr(0,200) +"\n";
debug_opti+="\n";
if(t.settings["debug"]){
var ch =changes;
debug_opti= ( doSyntaxOpti?"Optimisation": "No optimisation" )
+" start: "+ch.posStart +"("+ch.lineStart+")"
+" end_new: "+ ch.posNewEnd+"("+ch.lineNewEnd+")"
+" end_last: "+ ch.posLastEnd+"("+ch.lineLastEnd+")"
+"\nchanged_text: "+ch.newText+" => trace: "+trace_new
+"\nchanged_last_text: "+ch.lastText+" => trace: "+trace_last
//debug_opti+= "\nchanged: "+ infos["full_text"].substring(ch.posStart, ch.posNewEnd);
+ "\nchanged_line: "+ch.newTextLine
+ "\nlast_changed_line: "+ch.lastTextLine
+"\nstay_begin: "+ stay_begin.slice(-100)
+"\nstay_end: "+ stay_end.substr( 0, 100 );
//debug_opti="start: "+stay_begin_len+ "("+nb_line_start_unchanged+") end: "+ (stay_end_len)+ "("+(splited.length-nb_line_end_unchanged)+") ";
//debug_opti+="changed: "+ textToHighlight.substring(stay_begin_len, textToHighlight.length-stay_end_len)+" \n";
//debug_opti+="changed: "+ stay_begin.substr(stay_begin.length-200)+ "----------"+ textToHighlight+"------------------"+ stay_end.substr(0,200) +"\n";
+"\n";
}
// END OPTIMISATION
}
date= new Date();
tps_end_opti=date.getTime();
tps_end_opti = new Date().getTime();
// apply highlight
var updated_highlight= this.colorize_text(text_to_highlight);
updated_highlight = t.colorize_text(textToHighlight);
tpsAfterReg = new Date().getTime();
// get the new highlight content
/***
* see if we can optimize for updating only the required part of the HTML code
*
* The goal here will be to find the text node concerned by the modification and to update it
*/
//-------------------------------------------
//
if( doSyntaxOpti )
{
try
{
var replacedBloc, i, nbStart = '', nbEnd = '', newHtml, lengthOld, lengthNew;
replacedBloc = t.last_hightlighted_text.substring( stay_begin.length, t.last_hightlighted_text.length - stay_end.length );
lengthOld = replacedBloc.length;
lengthNew = updated_highlight.length;
// find the identical caracters at the beginning
for( i=0; i < lengthOld && i < lengthNew && replacedBloc.charAt(i) == updated_highlight.charAt(i) ; i++ )
{
}
nbStart = i;
// find the identical caracters at the end
for( i=0; i + nbStart < lengthOld && i + nbStart < lengthNew && replacedBloc.charAt(lengthOld-i-1) == updated_highlight.charAt(lengthNew-i-1) ; i++ )
{
}
nbEnd = i;
// get the changes
lastHtml = replacedBloc.substring( nbStart, lengthOld - nbEnd );
newHtml = updated_highlight.substring( nbStart, lengthNew - nbEnd );
// We can do the optimisation only if we havn't touch to span elements
if( newHtml.indexOf('<span') == -1 && newHtml.indexOf('</span') == -1
&& lastHtml.indexOf('<span') == -1 && lastHtml.indexOf('</span') == -1 )
{
var beginStr, nbOpendedSpan, nbClosedSpan, nbUnchangedChars, span, textNode;
doHtmlOpti = true;
beginStr = t.last_hightlighted_text.substr( 0, stay_begin.length + nbStart );
date= new Date();
tps2=date.getTime();
//updated_highlight= "<div class='keywords'>"+updated_highlight+"</div>";
var hightlighted_text= stay_begin + updated_highlight + stay_end;
//this.previous_hightlight_content= tab_text.join("<br>");
date= new Date();
inner1=date.getTime();
nbOpendedSpan = beginStr.split('<span').length - 1;
nbClosedSpan = beginStr.split('</span').length - 1;
// retrieve the previously opened span (Add 1 for the first level span?)
span = t.content_highlight.getElementsByTagName('span')[ nbOpendedSpan ];
// update the content of the highlight div by first updating a clone node (as there is no display in the same time for this node it's quite faster (5*))
var new_Obj= this.content_highlight.cloneNode(false);
if(this.nav['isIE'] || this.nav['isOpera'] || this.nav['isFirefox'] >= 3 )
new_Obj.innerHTML= "<pre><span class='"+ this.settings["syntax"] +"'>" + hightlighted_text.replace("\n", "<br/>") + "</span></pre>";
else
new_Obj.innerHTML= "<span class='"+ this.settings["syntax"] +"'>"+ hightlighted_text +"</span>";
this.content_highlight.parentNode.replaceChild(new_Obj, this.content_highlight);
this.content_highlight= new_Obj;
if(infos["full_text"].indexOf("\r")!=-1)
this.last_text_to_highlight= infos["full_text"].replace(/\r/g, "");
else
this.last_text_to_highlight= infos["full_text"];
this.last_hightlighted_text= hightlighted_text;
date= new Date();
tps3=date.getTime();
//--------[
// get the textNode to update
// if we're inside a span, we'll take the one that is opened (can be a parent of the current span)
parentSpan = span;
maxStartOffset = maxEndOffset = 0;
// it will be in the child of the root node
if( nbOpendedSpan == nbClosedSpan )
{
while( parentSpan.parentNode != t.content_highlight && parentSpan.parentNode.tagName != 'PRE' )
{
parentSpan = parentSpan.parentNode;
}
}
// get the last opened span
else
{
maxStartOffset = maxEndOffset = beginStr.length + 1;
// move to parent node for each closed span found after the lastest open span
nbClosed = beginStr.substr( Math.max( 0, beginStr.lastIndexOf( '<span', maxStartOffset - 1 ) ) ).split('</span').length - 1;
while( nbClosed > 0 )
{
nbClosed--;
parentSpan = parentSpan.parentNode;
}
// find the position of the last opended tag
while( parentSpan.parentNode != t.content_highlight && parentSpan.parentNode.tagName != 'PRE' && ( tmpMaxStartOffset = Math.max( 0, beginStr.lastIndexOf( '<span', maxStartOffset - 1 ) ) ) < ( tmpMaxEndOffset = Math.max( 0, beginStr.lastIndexOf( '</span', maxEndOffset - 1 ) ) ) )
{
maxStartOffset = tmpMaxStartOffset;
maxEndOffset = tmpMaxEndOffset;
}
}
// Note: maxEndOffset is no more used but maxStartOffset will be used
if( parentSpan.parentNode == t.content_highlight || parentSpan.parentNode.tagName == 'PRE' )
{
maxStartOffset = Math.max( 0, beginStr.indexOf( '<span' ) );
}
// find the matching text node (this will be one that will be at the end of the beginStr
if( maxStartOffset == beginStr.length )
{
nbSubSpanBefore = 0;
}
else
{
lastEndPos = Math.max( 0, beginStr.lastIndexOf( '>', maxStartOffset ) );
// count the number of sub spans
nbSubSpanBefore = beginStr.substr( lastEndPos ).split('<span').length-1;
}
// there is no sub-span before
if( nbSubSpanBefore == 0 )
{
textNode = parentSpan.firstChild;
}
// we need to find where is the text node modified
else
{
// take the last direct child (no sub-child)
lastSubSpan = parentSpan.getElementsByTagName('span')[ nbSubSpanBefore - 1 ];
while( lastSubSpan.parentNode != parentSpan )
{
lastSubSpan = lastSubSpan.parentNode;
}
// associate to next text node following the last sub span
if( lastSubSpan.nextSibling == null || lastSubSpan.nextSibling.nodeType != 3 )
{
textNode = document.createTextNode('');
lastSubSpan.parentNode.insertBefore( textNode, lastSubSpan.nextSibling );
}
else
{
textNode = lastSubSpan.nextSibling;
}
}
//--------]
//--------[
// update the textNode content
// number of caracters after the last opened of closed span
nbUnchangedChars = beginStr.length - Math.max( 0, beginStr.lastIndexOf( '>' ) + 1 );
// console.log( span, textNode, nbOpendedSpan,nbClosedSpan, span.nextSibling, textNode.length, nbUnchangedChars, lastHtml, lastHtml.length, newHtml, newHtml.length );
// alert( textNode.parentNode.className +'-'+ textNode.parentNode.tagName+"\n"+ textNode.data +"\n"+ nbUnchangedChars +"\n"+ lastHtml.length +"\n"+ newHtml +"\n"+ newHtml.length );
// IE only manage \r for cariage return in textNode and not \n or \r\n
if( t.isIE )
{
nbUnchangedChars -= ( beginStr.substr( beginStr.length - nbUnchangedChars ).split("\n").length - 1 );
//alert( textNode.data.replace(/\r/g, '_r').replace(/\n/g, '_n'));
textNode.replaceData( nbUnchangedChars, lastHtml.replace(/\n/g, '').length, newHtml.replace(/\n/g, '') );
}
else
{
textNode.replaceData( nbUnchangedChars, lastHtml.length, newHtml );
}
//--------]
}
}
// an exception shouldn't occured but if replaceData failed at least it won't break everything
catch( e )
{
// throw e;
// console.log( e );
doHtmlOpti = false;
}
}
/*** END HTML update's optimisation ***/
// end test
// console.log( (TPS6-TPS5), (TPS5-TPS4), (TPS4-TPS3), (TPS3-TPS2), (TPS2-TPS1), _CPT );
// get the new highlight content
tpsAfterOpti2 = new Date().getTime();
hightlighted_text = stay_begin + updated_highlight + stay_end;
if( !doHtmlOpti )
{
// update the content of the highlight div by first updating a clone node (as there is no display in the same time for t node it's quite faster (5*))
var new_Obj= t.content_highlight.cloneNode(false);
if( ( t.isIE && t.isIE < 8 ) || ( t.isOpera && t.isOpera < 9.6 ) )
new_Obj.innerHTML= "<pre><span class='"+ t.settings["syntax"] +"'>" + hightlighted_text + "</span></pre>";
else
new_Obj.innerHTML= "<span class='"+ t.settings["syntax"] +"'>"+ hightlighted_text +"</span>";
if(this.settings["debug"]){
tot1=tps_end_opti-tps_start;
tot_middle=tps_end_opti- tps_middle_opti;
tot2=tps2-tps_end_opti;
tps_join=inner1-tps2;
tps_td2=tps3-inner1;
t.content_highlight.parentNode.replaceChild(new_Obj, t.content_highlight);
t.content_highlight= new_Obj;
}
t.last_text_to_highlight= infos["full_text"];
t.last_hightlighted_text= hightlighted_text;
tps3=new Date().getTime();
if(t.settings["debug"]){
//lineNumber=tab_text.length;
//this.debug.value+=" \nNB char: "+$("src").value.length+" Nb line: "+ lineNumber;
this.debug.value= "Tps optimisation "+tot1+" (second part: "+tot_middle+") | tps reg exp: "+tot2+" | tps join: "+tps_join;
this.debug.value+= " | tps update highlight content: "+tps_td2+"("+tps3+")\n";
this.debug.value+=debug_opti;
// this.debug.value+= "highlight\n"+hightlighted_text;
//t.debug.value+=" \nNB char: "+_$("src").value.length+" Nb line: "+ lineNumber;
t.debug.value= "Tps optimisation "+(tps_end_opti-tps_start)
+" | tps reg exp: "+ (tpsAfterReg-tps_end_opti)
+" | tps opti HTML : "+ (tpsAfterOpti2-tpsAfterReg) + ' '+ ( doHtmlOpti ? 'yes' : 'no' )
+" | tps update highlight content: "+ (tps3-tpsAfterOpti2)
+" | tpsTotal: "+ (tps3-tps_start)
+ "("+tps3+")\n"+ debug_opti;
// t.debug.value+= "highlight\n"+hightlighted_text;*/
}
};
EditArea.prototype.resync_highlight= function(reload_now){
this.reload_highlight=true;
this.last_highlight_base_text="";
this.last_text_to_highlight="";
this.focus();
if(reload_now)
this.check_line_selection(false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

View file

@ -11,7 +11,7 @@ function keyDown(e){
for(var i in editArea.plugins){
if(typeof(editArea.plugins[i].onkeydown)=="function"){
if(editArea.plugins[i].onkeydown(e)===false){ // stop propaging
if(editArea.nav['isIE'])
if(editArea.isIE)
e.keyCode=0;
return false;
}
@ -27,10 +27,10 @@ function keyDown(e){
var low_letter= letter.toLowerCase();
if(letter=="Page up" && !editArea.nav['isOpera']){
if(letter=="Page up" && !editArea.isOpera){
editArea.execCommand("scroll_page", {"dir": "up", "shift": ShiftPressed(e)});
use=true;
}else if(letter=="Page down" && !editArea.nav['isOpera']){
}else if(letter=="Page down" && !editArea.isOpera){
editArea.execCommand("scroll_page", {"dir": "down", "shift": ShiftPressed(e)});
use=true;
}else if(editArea.is_editable==false){
@ -43,7 +43,7 @@ function keyDown(e){
editArea.execCommand("tab_selection");
use=true;
if(editArea.nav['isOpera'] || (editArea.nav['isFirefox'] && editArea.nav['isMacOS']) ) // opera && firefox mac can't cancel tabulation events...
if(editArea.isOpera || (editArea.isFirefox && editArea.isMac) ) // opera && firefox mac can't cancel tabulation events...
setTimeout("editArea.execCommand('focus');", 1);
}else if(letter=="Entrer" && target_id=="textarea"){
if(editArea.press_enter())
@ -103,7 +103,7 @@ function keyDown(e){
if(use){
// in case of a control that sould'nt be used by IE but that is used => THROW a javascript error that will stop key action
if(editArea.nav['isIE'])
if(editArea.isIE)
e.keyCode=0;
return false;
}

View file

@ -0,0 +1,73 @@
/*
* Bulgarian translation
* Author: Valentin Hristov
* Company: SOFTKIT Bulgarian
* Site: http://www.softkit-bg.com
*/
editAreaLoader.lang["bg"]={
new_document: "нов документ",
search_button: "търсене и замяна",
search_command: "търси следващия / отвори прозорец с търсачка",
search: "търсене",
replace: "замяна",
replace_command: "замяна / отвори прозорец с търсачка",
find_next: "намери следващия",
replace_all: "замени всички",
reg_exp: "реголярни изрази",
match_case: "чуствителен към регистъра",
not_found: "няма резултат.",
occurrence_replaced: "замяната е осъществена.",
search_field_empty: "Полето за търсене е празно",
restart_search_at_begin: "До края на документа. Почни с началото.",
move_popup: "премести прозореца с търсачката",
font_size: "--Размер на шрифта--",
go_to_line: "премени към реда",
go_to_line_prompt: "премени към номера на реда:",
undo: "отмени",
redo: "върни",
change_smooth_selection: "включи/изключи някой от функциите за преглед (по красиво, но повече натоварва)",
highlight: "превключване на оцветяване на синтаксиса включена/изключена",
reset_highlight: "въстанови оцветяване на синтаксиса (ако не е синхронизиран с текста)",
word_wrap: "режим на пренасяне на дълги редове",
help: "за програмата",
save: "съхрани",
load: "зареди",
line_abbr: "Стр",
char_abbr: "Стлб",
position: "Позиция",
total: "Всичко",
close_popup: "затвори прозореца",
shortcuts: "Бързи клавиши",
add_tab: "добави табулация в текста",
remove_tab: "премахни табулацията в текста",
about_notice: "Внимание: използвайте функцията оцветяване на синтаксиса само за малки текстове",
toggle: "Превключи редактор",
accesskey: "Бърз клавиш",
tab: "Tab",
shift: "Shift",
ctrl: "Ctrl",
esc: "Esc",
processing: "Зареждане...",
fullscreen: "на цял екран",
syntax_selection: "--Синтаксис--",
syntax_css: "CSS",
syntax_html: "HTML",
syntax_js: "Javascript",
syntax_php: "PHP",
syntax_python: "Python",
syntax_vb: "Visual Basic",
syntax_xml: "XML",
syntax_c: "C",
syntax_cpp: "C++",
syntax_basic: "Basic",
syntax_pas: "Pascal",
syntax_brainfuck: "Brainfuck",
syntax_sql: "SQL",
syntax_ruby: "Ruby",
syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Затвори файла"
};

View file

@ -22,6 +22,7 @@ redo: "znovu",
change_smooth_selection: "Povolit nebo zakázat některé ze zobrazených funkcí (účelnější zobrazení požaduje větší zatížení procesoru)",
highlight: "Zvýrazňování syntaxe zap./vyp.",
reset_highlight: "Obnovit zvýraznění (v případě nesrovnalostí)",
word_wrap: "toggle word wrapping mode",
help: "O programu",
save: "Uložit",
load: "Otevřít",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "Wiederherstellen",
change_smooth_selection: "Aktiviere/Deaktiviere einige Features (weniger Bildschirmnutzung aber mehr CPU-Belastung)",
highlight: "Syntax Highlighting an- und ausschalten",
reset_highlight: "Highlighting zur&uuml;cksetzen (falls mit Text nicht konform)",
word_wrap: "Toggle word wrapping mode",
help: "Info",
save: "Speichern",
load: "&Ouml;ffnen",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "gentag",
change_smooth_selection: "sl&aring; display funktioner til/fra (smartere display men mere CPU kr&aelig;vende)",
highlight: "sl&aring; syntax highlight til/fra",
reset_highlight: "nulstil highlight (hvis den er desynkroniseret fra teksten)",
word_wrap: "toggle word wrapping mode",
help: "om",
save: "gem",
load: "hent",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "redo",
change_smooth_selection: "enable/disable some display features (smarter display but more CPU charge)",
highlight: "toggle syntax highlight on/off",
reset_highlight: "reset highlight (if desyncronized from text)",
word_wrap: "toggle word wrapping mode",
help: "about",
save: "save",
load: "load",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "refari",
change_smooth_selection: "ebligi/malebligi la funkcioj de vidigo (pli bona vidigo, sed pli da &#349;ar&#285;o de la &#265;eforgano)",
highlight: "ebligi/malebligi la sintaksan kolorigon",
reset_highlight: "repravalorizi la sintaksan kolorigon (se malsinkronigon de la teksto)",
word_wrap: "toggle word wrapping mode",
help: "pri",
save: "registri",
load: "&#349;ar&#285;i",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Fermi la dosieron"
};

View file

@ -22,6 +22,7 @@ redo: "rehacer",
change_smooth_selection: "activar/desactivar algunas características de visualización (visualización más inteligente pero más carga de CPU)",
highlight: "intercambiar resaltado de sintaxis",
reset_highlight: "reinicializar resaltado (si no esta sincronizado con el texto)",
word_wrap: "toggle word wrapping mode",
help: "acerca",
save: "guardar",
load: "cargar",
@ -58,5 +59,6 @@ syntax_brainfuck: "Brainfuck",
syntax_sql: "SQL",
syntax_ruby: "Ruby",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -0,0 +1,67 @@
editAreaLoader.lang["fi"]={
new_document: "uusi tyhjä dokumentti",
search_button: "etsi ja korvaa",
search_command: "etsi seuraava / avaa etsintävalikko",
search: "etsi",
replace: "korvaa",
replace_command: "korvaa / avaa etsintävalikko",
find_next: "etsi seuraava",
replace_all: "korvaa kaikki",
reg_exp: "säännölliset lausekkeet",
match_case: "täsmää kirjainkokoon",
not_found: "ei löytynyt.",
occurrence_replaced: "esiintymää korvattu.",
search_field_empty: "Haettava merkkijono on tyhjä",
restart_search_at_begin: "Alueen loppu saavutettiin. Aloitetaan alusta.",
move_popup: "siirrä etsintävalikkoa",
font_size: "--Fontin koko--",
go_to_line: "siirry riville",
go_to_line_prompt: "mene riville:",
undo: "peruuta",
redo: "tee uudelleen",
change_smooth_selection: "kytke/sammuta joitakin näyttötoimintoja (Älykkäämpi toiminta, mutta suurempi CPU kuormitus)",
highlight: "kytke syntaksikorostus päälle/pois",
reset_highlight: "resetoi syntaksikorostus (jos teksti ei ole synkassa korostuksen kanssa)",
word_wrap: "toggle word wrapping mode",
help: "tietoja",
save: "tallenna",
load: "lataa",
line_abbr: "Rv",
char_abbr: "Pos",
position: "Paikka",
total: "Yhteensä",
close_popup: "sulje valikko",
shortcuts: "Pikatoiminnot",
add_tab: "lisää sisennys tekstiin",
remove_tab: "poista sisennys tekstistä",
about_notice: "Huomautus: syntaksinkorostus toimii vain pienelle tekstille",
toggle: "Kytke editori",
accesskey: "Pikanäppäin",
tab: "Tab",
shift: "Shift",
ctrl: "Ctrl",
esc: "Esc",
processing: "Odota...",
fullscreen: "koko ruutu",
syntax_selection: "--Syntaksi--",
syntax_css: "CSS",
syntax_html: "HTML",
syntax_js: "Javascript",
syntax_php: "Php",
syntax_python: "Python",
syntax_vb: "Visual Basic",
syntax_xml: "Xml",
syntax_c: "C",
syntax_cpp: "CPP",
syntax_basic: "Basic",
syntax_pas: "Pascal",
syntax_brainfuck: "Brainfuck",
syntax_sql: "SQL",
syntax_ruby: "Ruby",
syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Sulje tiedosto"
};

View file

@ -22,6 +22,7 @@ redo: "refaire",
change_smooth_selection: "activer/d&eacute;sactiver des fonctions d'affichage (meilleur affichage mais plus de charge processeur)",
highlight: "activer/d&eacute;sactiver la coloration syntaxique",
reset_highlight: "r&eacute;initialiser la coloration syntaxique (si d&eacute;syncronis&eacute;e du texte)",
word_wrap: "activer/d&eacute;sactiver les retours &agrave; la ligne automatiques",
help: "&agrave; propos",
save: "sauvegarder",
load: "charger",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Fermer le fichier"
};

View file

@ -22,6 +22,7 @@ redo: "Napravi ponovo",
change_smooth_selection: "Ukljuèi/iskljuèi neke moguænosti prikaza (pametniji prikaz, ali zagušeniji CPU)",
highlight: "Ukljuèi/iskljuèi bojanje sintakse",
reset_highlight: "Ponovi kolorizaciju (ako je nesinkronizirana s tekstom)",
word_wrap: "toggle word wrapping mode",
help: "O edit_area",
save: "Spremi",
load: "Uèitaj",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "ripeti",
change_smooth_selection: "abilita/disabilita alcune caratteristiche della visualizzazione",
highlight: "abilita/disabilita colorazione della sintassi",
reset_highlight: "aggiorna colorazione (se non sincronizzata)",
word_wrap: "toggle word wrapping mode",
help: "informazioni su...",
save: "salva",
load: "carica",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "やり直し",
change_smooth_selection: "スムース表示の切り替えCPUを使います",
highlight: "構文強調表示の切り替え",
reset_highlight: "構文強調表示のリセット",
word_wrap: "toggle word wrapping mode",
help: "ヘルプを表示",
save: "保存",
load: "読み込み",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "Повтори",
change_smooth_selection: "Вклучи/исклучи некои карактеристики за приказ (попаметен приказ, но поголемо оптеретување за процесорот)",
highlight: "Вклучи/исклучи осветлување на синтакса",
reset_highlight: "Ресетирај го осветлувањето на синтакса (доколку е десинхронизиранo со текстот)",
word_wrap: "toggle word wrapping mode",
help: "За",
save: "Зачувај",
load: "Вчитај",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Избери датотека"
};

View file

@ -22,6 +22,7 @@ redo: "Opnieuw doen",
change_smooth_selection: "zet wat schermopties aan/uit (kan langzamer zijn)",
highlight: "zet syntax highlight aan/uit",
reset_highlight: "reset highlight (indien gedesynchronizeerd)",
word_wrap: "toggle word wrapping mode",
help: "informatie",
save: "opslaan",
load: "laden",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "przywróć",
change_smooth_selection: "włącz/wyłącz niektóre opcje wyglądu (zaawansowane opcje wyglądu obciążają procesor)",
highlight: "włącz/wyłącz podświetlanie składni",
reset_highlight: "odśwież podświetlanie składni (jeśli rozsynchronizowało się z tekstem)",
word_wrap: "toggle word wrapping mode",
help: "o programie",
save: "zapisz",
load: "otwórz",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "Refazer",
change_smooth_selection: "Opções visuais",
highlight: "Cores de sintaxe",
reset_highlight: "Resetar cores (se não sincronizado)",
word_wrap: "toggle word wrapping mode",
help: "Sobre",
save: "Salvar",
load: "Carregar",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -22,6 +22,7 @@ redo: "вернуть",
change_smooth_selection: "включить/отключить некоторые функции просмотра (более красиво, но больше использует процессор)",
highlight: "переключить подсветку синтаксиса включена/выключена",
reset_highlight: "восстановить подсветку (если разсинхронизирована от текста)",
word_wrap: "toggle word wrapping mode",
help: "о программе",
save: "сохранить",
load: "загрузить",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Закрыть файл"
};

View file

@ -22,6 +22,7 @@ redo: "prepracovať",
change_smooth_selection: "povoliť/zamietnúť niektoré zo zobrazených funkcií (účelnejšie zobrazenie vyžaduje väčšie zaťaženie procesora CPU)",
highlight: "prepnúť zvýrazňovanie syntaxe zap/vyp",
reset_highlight: "zrušiť zvýrazňovanie (ak je nesynchronizované s textom)",
word_wrap: "toggle word wrapping mode",
help: "o programe",
save: "uložiť",
load: "načítať",
@ -61,5 +62,6 @@ syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "Close file"
};

View file

@ -0,0 +1,67 @@
editAreaLoader.lang["zh"]={
new_document: "新建空白文档",
search_button: "查找与替换",
search_command: "查找下一个 / 打开查找框",
search: "查找",
replace: "替换",
replace_command: "替换 / 打开查找框",
find_next: "查找下一个",
replace_all: "全部替换",
reg_exp: "正则表达式",
match_case: "匹配大小写",
not_found: "未找到.",
occurrence_replaced: "处被替换.",
search_field_empty: "查找框没有内容",
restart_search_at_begin: "已到到文档末尾. 从头重新查找.",
move_popup: "移动查找对话框",
font_size: "--字体大小--",
go_to_line: "转到行",
go_to_line_prompt: "转到行:",
undo: "恢复",
redo: "重做",
change_smooth_selection: "启用/禁止一些显示特性(更好看但更耗费资源)",
highlight: "启用/禁止语法高亮",
reset_highlight: "重置语法高亮(当文本显示不同步时)",
word_wrap: "toggle word wrapping mode",
help: "关于",
save: "保存",
load: "加载",
line_abbr: "行",
char_abbr: "字符",
position: "位置",
total: "总计",
close_popup: "关闭对话框",
shortcuts: "快捷键",
add_tab: "添加制表符(Tab)",
remove_tab: "移除制表符(Tab)",
about_notice: "注意:语法高亮功能仅用于较少内容的文本(文件内容太大会导致浏览器反应慢)",
toggle: "切换编辑器",
accesskey: "快捷键",
tab: "Tab",
shift: "Shift",
ctrl: "Ctrl",
esc: "Esc",
processing: "正在处理中...",
fullscreen: "全屏编辑",
syntax_selection: "--语法--",
syntax_css: "CSS",
syntax_html: "HTML",
syntax_js: "Javascript",
syntax_php: "Php",
syntax_python: "Python",
syntax_vb: "Visual Basic",
syntax_xml: "Xml",
syntax_c: "C",
syntax_cpp: "CPP",
syntax_basic: "Basic",
syntax_pas: "Pascal",
syntax_brainfuck: "Brainfuck",
syntax_sql: "SQL",
syntax_ruby: "Ruby",
syntax_robotstxt: "Robots txt",
syntax_tsql: "T-SQL",
syntax_perl: "Perl",
syntax_coldfusion: "Coldfusion",
syntax_java: "Java",
close_tab: "关闭文件"
};

View file

@ -0,0 +1,7 @@
Copyright 2008 Christophe Dolivet
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

View file

@ -0,0 +1,10 @@
Copyright (c) 2008, Christophe Dolivet
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of EditArea nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,458 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. 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 not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the 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
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS

View file

@ -5,64 +5,90 @@
EditArea.prototype.check_line_selection= function(timer_checkup){
//if(do_highlight==false){
var changes, infos, new_top, new_width,i;
var t1=t2=t2_1=t3=tLines=tend= new Date().getTime();
// l'editeur n'existe plus => on quitte
if(!editAreas[this.id])
return false;
//time=new Date;
//t1=t2=t3= time.getTime();
if(!this.smooth_selection && !this.do_highlight)
{
//do nothing
}
else if(this.textareaFocused && editAreas[this.id]["displayed"]==true && this.isResizing==false)
{
infos = this.get_selection_infos();
changes = this.checkTextEvolution( typeof( this.last_selection['full_text'] ) == 'undefined' ? '' : this.last_selection['full_text'], infos['full_text'] );
if(!this.smooth_selection && !this.do_highlight){
//formatArea();
}else if(this.textareaFocused && editAreas[this.id]["displayed"]==true && this.isResizing==false){
infos= this.get_selection_infos();
// time=new Date;
// t2= time.getTime();
t2= new Date().getTime();
//if(this.last_selection["line_start"] != infos["line_start"] || this.last_selection["line_nb"] != infos["line_nb"] || infos["full_text"] != this.last_selection["full_text"]){
if(this.last_selection["line_start"] != infos["line_start"] || this.last_selection["line_nb"] != infos["line_nb"] || infos["full_text"] != this.last_selection["full_text"] || this.reload_highlight){
// if selection change
if(this.last_selection["line_start"] != infos["line_start"] || this.last_selection["line_nb"] != infos["line_nb"] || infos["full_text"] != this.last_selection["full_text"] || this.reload_highlight || this.last_selection["selectionStart"] != infos["selectionStart"] || this.last_selection["selectionEnd"] != infos["selectionEnd"] || !timer_checkup )
{
// move and adjust text selection elements
new_top = this.getLinePosTop( infos["line_start"] );
new_width = Math.max(this.textarea.scrollWidth, this.container.clientWidth -50);
this.selection_field.style.top=this.selection_field_text.style.top=new_top+"px";
if(!this.settings['word_wrap']){
this.selection_field.style.width=this.selection_field_text.style.width=this.test_font_size.style.width=new_width+"px";
}
new_top=this.lineHeight * (infos["line_start"]-1);
new_height=Math.max(0, this.lineHeight * infos["line_nb"]);
new_width=Math.max(this.textarea.scrollWidth, this.container.clientWidth -50);
this.selection_field.style.top=new_top+"px";
this.selection_field.style.width=new_width+"px";
this.selection_field.style.height=new_height+"px";
$("cursor_pos").style.top=new_top+"px";
// usefull? => _$("cursor_pos").style.top=new_top+"px";
if(this.do_highlight==true){
var curr_text=infos["full_text"].split("\n");
var content="";
if(this.do_highlight==true)
{
// fill selection elements
var curr_text = infos["full_text"].split("\n");
var content = "";
//alert("length: "+curr_text.length+ " i: "+ Math.max(0,infos["line_start"]-1)+ " end: "+Math.min(curr_text.length, infos["line_start"]+infos["line_nb"]-1)+ " line: "+infos["line_start"]+" [0]: "+curr_text[0]+" [1]: "+curr_text[1]);
var start=Math.max(0,infos["line_start"]-1);
var end=Math.min(curr_text.length, infos["line_start"]+infos["line_nb"]-1);
var start = Math.max(0,infos["line_start"]-1);
var end = Math.min(curr_text.length, infos["line_start"]+infos["line_nb"]-1);
//curr_text[start]= curr_text[start].substr(0,infos["curr_pos"]-1) +"¤_overline_¤"+ curr_text[start].substr(infos["curr_pos"]-1);
for(i=start; i< end; i++){
content+= curr_text[i]+"\n";
}
content= content.replace(/&/g,"&amp;");
content= content.replace(/</g,"&lt;");
content= content.replace(/>/g,"&gt;");
// add special chars arround selected characters
selLength = infos['selectionEnd'] - infos['selectionStart'];
content = content.substr( 0, infos["curr_pos"] - 1 ) + "\r\r" + content.substr( infos["curr_pos"] - 1, selLength ) + "\r\r" + content.substr( infos["curr_pos"] - 1 + selLength );
content = '<span>'+ content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace("\r\r", '</span><strong>').replace("\r\r", '</strong><span>') +'</span>';
if(this.nav['isIE'] || this.nav['isOpera'] || this.nav['isFirefox'] >= 3)
this.selection_field.innerHTML= "<pre>" + content.replace("\n", "<br/>") + "</pre>";
else
this.selection_field.innerHTML=content;
if(this.reload_highlight || (infos["full_text"] != this.last_text_to_highlight && (this.last_selection["line_start"]!=infos["line_start"] || this.show_line_colors || this.last_selection["line_nb"]!=infos["line_nb"] || this.last_selection["nb_line"]!=infos["nb_line"]) ) )
if( this.isIE || ( this.isOpera && this.isOpera < 9.6 ) ) {
this.selection_field.innerHTML= "<pre>" + content.replace(/^\r?\n/, "<br>") + "</pre>";
} else {
this.selection_field.innerHTML= content;
}
this.selection_field_text.innerHTML = this.selection_field.innerHTML;
t2_1 = new Date().getTime();
// check if we need to update the highlighted background
if(this.reload_highlight || (infos["full_text"] != this.last_text_to_highlight && (this.last_selection["line_start"]!=infos["line_start"] || this.show_line_colors || this.settings['word_wrap'] || this.last_selection["line_nb"]!=infos["line_nb"] || this.last_selection["nb_line"]!=infos["nb_line"]) ) )
{
this.maj_highlight(infos);
}
}
}
// time=new Date;
// t3= time.getTime();
t3= new Date().getTime();
// manage line heights
if( this.settings['word_wrap'] && infos["full_text"] != this.last_selection["full_text"])
{
// refresh only 1 line if text change concern only one line and that the total line number has not changed
if( changes.newText.split("\n").length == 1 && this.last_selection['nb_line'] && infos['nb_line'] == this.last_selection['nb_line'] )
{
this.fixLinesHeight( infos['full_text'], changes.lineStart, changes.lineStart );
}
else
{
this.fixLinesHeight( infos['full_text'], changes.lineStart, -1 );
}
}
tLines= new Date().getTime();
// manage bracket finding
if(infos["line_start"] != this.last_selection["line_start"] || infos["curr_pos"] != this.last_selection["curr_pos"] || infos["full_text"].length!=this.last_selection["full_text"].length || this.reload_highlight){
if( infos["line_start"] != this.last_selection["line_start"] || infos["curr_pos"] != this.last_selection["curr_pos"] || infos["full_text"].length!=this.last_selection["full_text"].length || this.reload_highlight || !timer_checkup )
{
// move _cursor_pos
var selec_char= infos["curr_line"].charAt(infos["curr_pos"]-1);
var no_real_move=true;
@ -71,17 +97,17 @@
no_real_move=false;
//findEndBracket(infos["line_start"], infos["curr_pos"], selec_char);
if(this.findEndBracket(infos, selec_char) === true){
$("end_bracket").style.visibility="visible";
$("cursor_pos").style.visibility="visible";
$("cursor_pos").innerHTML= selec_char;
$("end_bracket").innerHTML= (this.assocBracket[selec_char] || this.revertAssocBracket[selec_char]);
_$("end_bracket").style.visibility ="visible";
_$("cursor_pos").style.visibility ="visible";
_$("cursor_pos").innerHTML = selec_char;
_$("end_bracket").innerHTML = (this.assocBracket[selec_char] || this.revertAssocBracket[selec_char]);
}else{
$("end_bracket").style.visibility="hidden";
$("cursor_pos").style.visibility="hidden";
_$("end_bracket").style.visibility ="hidden";
_$("cursor_pos").style.visibility ="hidden";
}
}else{
$("cursor_pos").style.visibility="hidden";
$("end_bracket").style.visibility="hidden";
_$("cursor_pos").style.visibility ="hidden";
_$("end_bracket").style.visibility ="hidden";
}
//alert("move cursor");
this.displayToCursorPosition("cursor_pos", infos["line_start"], infos["curr_pos"]-1, infos["curr_line"], no_real_move);
@ -90,140 +116,213 @@
}
this.last_selection=infos;
}
// time=new Date;
// tend= time.getTime();
//this.debug.value="tps total: "+ (tend-t1) + " tps get_infos: "+ (t2-t1)+ " tps jaune: "+ (t3-t2) +" tps cursor: "+ (tend-t3)+" "+typeof(infos);
tend= new Date().getTime();
//if( (tend-t1) > 7 )
// console.log( "tps total: "+ (tend-t1) + " tps get_infos: "+ (t2-t1)+ " tps selec: "+ (t2_1-t2)+ " tps highlight: "+ (t3-t2_1) +" tps lines: "+ (tLines-t3) +" tps cursor+lines: "+ (tend-tLines)+" \n" );
if(timer_checkup){
//if(this.do_highlight==true) //can slow down check speed when highlight mode is on
setTimeout("editArea.check_line_selection(true)", this.check_line_selection_timer);
}
};
EditArea.prototype.get_selection_infos= function(){
if(this.nav['isIE'])
this.getIESelection();
start=this.textarea.selectionStart;
end=this.textarea.selectionEnd;
var sel={}, start, end, len, str;
this.getIESelection();
start = this.textarea.selectionStart;
end = this.textarea.selectionEnd;
if(this.last_selection["selectionStart"]==start && this.last_selection["selectionEnd"]==end && this.last_selection["full_text"]==this.textarea.value)
if( this.last_selection["selectionStart"] == start && this.last_selection["selectionEnd"] == end && this.last_selection["full_text"] == this.textarea.value )
{
return this.last_selection;
}
if(this.tabulation!="\t" && this.textarea.value.indexOf("\t")!=-1)
{ // can append only after copy/paste
var len= this.textarea.value.length;
this.textarea.value=this.replace_tab(this.textarea.value);
start=end= start+(this.textarea.value.length-len);
this.area_select(start, 0);
len = this.textarea.value.length;
this.textarea.value = this.replace_tab(this.textarea.value);
start = end = start+(this.textarea.value.length-len);
this.area_select( start, 0 );
}
var selections=new Object();
selections["selectionStart"]= start;
selections["selectionEnd"]= end;
selections["full_text"]= this.textarea.value;
selections["line_start"]=1;
selections["line_nb"]=1;
selections["curr_pos"]=0;
selections["curr_line"]="";
selections["indexOfCursor"]=0;
selections["selec_direction"]= this.last_selection["selec_direction"];
//return selections;
var splitTab=selections["full_text"].split("\n");
var nbLine=Math.max(0, splitTab.length);
var nbChar=Math.max(0, selections["full_text"].length - (nbLine - 1)); // (remove \n caracters from the count)
if(selections["full_text"].indexOf("\r")!=-1)
nbChar= nbChar - (nbLine -1); // (remove \r caracters from the count)
selections["nb_line"]=nbLine;
selections["nb_char"]=nbChar;
sel["selectionStart"] = start;
sel["selectionEnd"] = end;
sel["full_text"] = this.textarea.value;
sel["line_start"] = 1;
sel["line_nb"] = 1;
sel["curr_pos"] = 0;
sel["curr_line"] = "";
sel["indexOfCursor"] = 0;
sel["selec_direction"] = this.last_selection["selec_direction"];
//return sel;
var splitTab= sel["full_text"].split("\n");
var nbLine = Math.max(0, splitTab.length);
var nbChar = Math.max(0, sel["full_text"].length - (nbLine - 1)); // (remove \n caracters from the count)
if( sel["full_text"].indexOf("\r") != -1 )
nbChar = nbChar - ( nbLine - 1 ); // (remove \r caracters from the count)
sel["nb_line"] = nbLine;
sel["nb_char"] = nbChar;
if(start>0){
var str=selections["full_text"].substr(0,start);
selections["curr_pos"]= start - str.lastIndexOf("\n");
selections["line_start"]=Math.max(1, str.split("\n").length);
str = sel["full_text"].substr(0,start);
sel["curr_pos"] = start - str.lastIndexOf("\n");
sel["line_start"] = Math.max(1, str.split("\n").length);
}else{
selections["curr_pos"]=1;
sel["curr_pos"]=1;
}
if(end>start){
selections["line_nb"]=selections["full_text"].substring(start,end).split("\n").length;
sel["line_nb"]=sel["full_text"].substring(start,end).split("\n").length;
}
selections["indexOfCursor"]=this.textarea.selectionStart;
selections["curr_line"]=splitTab[Math.max(0,selections["line_start"]-1)];
// determine in with direction the direction grow
if(selections["selectionStart"]==this.last_selection["selectionStart"]){
if(selections["selectionEnd"]>this.last_selection["selectionEnd"])
selections["selec_direction"]= "down";
else if(selections["selectionEnd"] == this.last_selection["selectionStart"])
selections["selec_direction"]= this.last_selection["selec_direction"];
}else if(selections["selectionStart"] == this.last_selection["selectionEnd"] && selections["selectionEnd"]>this.last_selection["selectionEnd"]){
selections["selec_direction"]= "down";
sel["indexOfCursor"]=start;
sel["curr_line"]=splitTab[Math.max(0,sel["line_start"]-1)];
// determine in which direction the selection grow
if(sel["selectionStart"] == this.last_selection["selectionStart"]){
if(sel["selectionEnd"]>this.last_selection["selectionEnd"])
sel["selec_direction"]= "down";
else if(sel["selectionEnd"] == this.last_selection["selectionStart"])
sel["selec_direction"]= this.last_selection["selec_direction"];
}else if(sel["selectionStart"] == this.last_selection["selectionEnd"] && sel["selectionEnd"]>this.last_selection["selectionEnd"]){
sel["selec_direction"]= "down";
}else{
selections["selec_direction"]= "up";
sel["selec_direction"]= "up";
}
$("nbLine").innerHTML= nbLine;
$("nbChar").innerHTML= nbChar;
$("linePos").innerHTML=selections["line_start"];
$("currPos").innerHTML=selections["curr_pos"];
return selections;
_$("nbLine").innerHTML = nbLine;
_$("nbChar").innerHTML = nbChar;
_$("linePos").innerHTML = sel["line_start"];
_$("currPos").innerHTML = sel["curr_pos"];
return sel;
};
// set IE position in Firefox mode (textarea.selectionStart and textarea.selectionEnd)
EditArea.prototype.getIESelection= function(){
var range = document.selection.createRange();
var stored_range = range.duplicate();
stored_range.moveToElementText( this.textarea );
stored_range.setEndPoint( 'EndToEnd', range );
if(stored_range.parentElement() !=this.textarea)
return;
// the range don't take care of empty lines in the end of the selection
var scrollTop= this.result.scrollTop + document.body.scrollTop;
EditArea.prototype.getIESelection= function(){
var selectionStart, selectionEnd, range, stored_range;
var relative_top= range.offsetTop - parent.calculeOffsetTop(this.textarea) + scrollTop;
if( !this.isIE )
return false;
// make it work as nowrap mode (easier for range manipulation with lineHeight)
if( this.settings['word_wrap'] )
this.textarea.wrap='off';
try{
range = document.selection.createRange();
stored_range = range.duplicate();
stored_range.moveToElementText( this.textarea );
stored_range.setEndPoint( 'EndToEnd', range );
if( stored_range.parentElement() != this.textarea )
throw "invalid focus";
// the range don't take care of empty lines in the end of the selection
var scrollTop = this.result.scrollTop + document.body.scrollTop;
var relative_top= range.offsetTop - parent.calculeOffsetTop(this.textarea) + scrollTop;
var line_start = Math.round((relative_top / this.lineHeight) +1);
var line_nb = Math.round( range.boundingHeight / this.lineHeight );
selectionStart = stored_range.text.length - range.text.length;
selectionStart += ( line_start - this.textarea.value.substr(0, selectionStart).split("\n").length)*2; // count missing empty \r to the selection
selectionStart -= ( line_start - this.textarea.value.substr(0, selectionStart).split("\n").length ) * 2;
selectionEnd = selectionStart + range.text.length;
selectionEnd += (line_start + line_nb - 1 - this.textarea.value.substr(0, selectionEnd ).split("\n").length)*2;
var line_start = Math.round((relative_top / this.lineHeight) +1);
this.textarea.selectionStart = selectionStart;
this.textarea.selectionEnd = selectionEnd;
}
catch(e){}
var line_nb=Math.round(range.boundingHeight / this.lineHeight);
var range_start=stored_range.text.length - range.text.length;
var tab=this.textarea.value.substr(0, range_start).split("\n");
range_start+= (line_start - tab.length)*2; // add missing empty lines to the selection
this.textarea.selectionStart = range_start;
var range_end=this.textarea.selectionStart + range.text.length;
tab=this.textarea.value.substr(0, range_start + range.text.length).split("\n");
range_end+= (line_start + line_nb - 1 - tab.length)*2;
this.textarea.selectionEnd = range_end;
/*this.textarea.selectionStart = 10;
this.textarea.selectionEnd = 50;*/
// restore wrap mode
if( this.settings['word_wrap'] )
this.textarea.wrap='soft';
};
// select the text for IE (and take care of \r caracters)
EditArea.prototype.setIESelection= function(){
var nbLineStart=this.textarea.value.substr(0, this.textarea.selectionStart).split("\n").length - 1;
var nbLineEnd=this.textarea.value.substr(0, this.textarea.selectionEnd).split("\n").length - 1;
var range = document.selection.createRange();
range.moveToElementText( this.textarea );
var a = this.textarea, nbLineStart, nbLineEnd, range;
if( !this.isIE )
return false;
nbLineStart = a.value.substr(0, a.selectionStart).split("\n").length - 1;
nbLineEnd = a.value.substr(0, a.selectionEnd).split("\n").length - 1;
range = document.selection.createRange();
range.moveToElementText( a );
range.setEndPoint( 'EndToStart', range );
range.moveStart('character', this.textarea.selectionStart - nbLineStart);
range.moveEnd('character', this.textarea.selectionEnd - nbLineEnd - (this.textarea.selectionStart - nbLineStart) );
range.moveStart('character', a.selectionStart - nbLineStart);
range.moveEnd('character', a.selectionEnd - nbLineEnd - (a.selectionStart - nbLineStart) );
range.select();
};
EditArea.prototype.checkTextEvolution=function(lastText,newText){
// ch will contain changes datas
var ch={},baseStep=200, cpt=0, end, step,tStart=new Date().getTime();
end = Math.min(newText.length, lastText.length);
step = baseStep;
// find how many chars are similar at the begin of the text
while( cpt<end && step>=1 ){
if(lastText.substr(cpt, step) == newText.substr(cpt, step)){
cpt+= step;
}else{
step= Math.floor(step/2);
}
}
ch.posStart = cpt;
ch.lineStart= newText.substr(0, ch.posStart).split("\n").length -1;
cpt_last = lastText.length;
cpt = newText.length;
step = baseStep;
// find how many chars are similar at the end of the text
while( cpt>=0 && cpt_last>=0 && step>=1 ){
if(lastText.substr(cpt_last-step, step) == newText.substr(cpt-step, step)){
cpt-= step;
cpt_last-= step;
}else{
step= Math.floor(step/2);
}
}
ch.posNewEnd = cpt;
ch.posLastEnd = cpt_last;
if(ch.posNewEnd<=ch.posStart){
if(lastText.length < newText.length){
ch.posNewEnd= ch.posStart + newText.length - lastText.length;
ch.posLastEnd= ch.posStart;
}else{
ch.posLastEnd= ch.posStart + lastText.length - newText.length;
ch.posNewEnd= ch.posStart;
}
}
ch.newText = newText.substring(ch.posStart, ch.posNewEnd);
ch.lastText = lastText.substring(ch.posStart, ch.posLastEnd);
ch.lineNewEnd = newText.substr(0, ch.posNewEnd).split("\n").length -1;
ch.lineLastEnd = lastText.substr(0, ch.posLastEnd).split("\n").length -1;
ch.newTextLine = newText.split("\n").slice(ch.lineStart, ch.lineNewEnd+1).join("\n");
ch.lastTextLine = lastText.split("\n").slice(ch.lineStart, ch.lineLastEnd+1).join("\n");
//console.log( ch );
return ch;
};
EditArea.prototype.tab_selection= function(){
if(this.is_tabbing)
return;
this.is_tabbing=true;
//infos=getSelectionInfos();
//if( document.selection ){
if( this.nav['isIE'] )
this.getIESelection();
this.getIESelection();
/* Insertion du code de formatage */
var start = this.textarea.selectionStart;
var end = this.textarea.selectionEnd;
@ -254,52 +353,56 @@
this.textarea.selectionEnd = pos_end;
//if( document.selection ){
if(this.nav['isIE']){
if(this.isIE)
{
this.setIESelection();
setTimeout("editArea.is_tabbing=false;", 100); // IE can't accept to make 2 tabulation without a little break between both
}else
this.is_tabbing=false;
}
else
{
this.is_tabbing=false;
}
};
EditArea.prototype.invert_tab_selection= function(){
if(this.is_tabbing)
var t=this, a=this.textarea;
if(t.is_tabbing)
return;
this.is_tabbing=true;
t.is_tabbing=true;
//infos=getSelectionInfos();
//if( document.selection ){
if(this.nav['isIE'])
this.getIESelection();
t.getIESelection();
var start = this.textarea.selectionStart;
var end = this.textarea.selectionEnd;
var insText = this.textarea.value.substring(start, end);
var start = a.selectionStart;
var end = a.selectionEnd;
var insText = a.value.substring(start, end);
/* Tab remove and cursor seleciton adjust */
var pos_start=start;
var pos_end=end;
if (insText.length == 0) {
if(this.textarea.value.substring(start-this.tabulation.length, start)==this.tabulation)
if(a.value.substring(start-t.tabulation.length, start)==t.tabulation)
{
this.textarea.value = this.textarea.value.substr(0, start-this.tabulation.length) + this.textarea.value.substr(end);
pos_start= Math.max(0, start-this.tabulation.length);
pos_end=pos_start;
a.value = a.value.substr(0, start-t.tabulation.length) + a.value.substr(end);
pos_start = Math.max(0, start-t.tabulation.length);
pos_end = pos_start;
}
/*
this.textarea.value = this.textarea.value.substr(0, start) + this.tabulation + insText + this.textarea.value.substr(end);
pos_start = start + this.tabulation.length;
a.value = a.value.substr(0, start) + t.tabulation + insText + a.value.substr(end);
pos_start = start + t.tabulation.length;
pos_end=pos_start;*/
} else {
start= this.textarea.value.substr(0, start).lastIndexOf("\n")+1;
endText=this.textarea.value.substr(end);
startText=this.textarea.value.substr(0, start);
tmp= this.textarea.value.substring(start, end).split("\n");
insText="";
start = a.value.substr(0, start).lastIndexOf("\n")+1;
endText = a.value.substr(end);
startText = a.value.substr(0, start);
tmp = a.value.substring(start, end).split("\n");
insText = "";
for(i=0; i<tmp.length; i++){
for(j=0; j<this.tab_nb_char; j++){
for(j=0; j<t.tab_nb_char; j++){
if(tmp[i].charAt(0)=="\t"){
tmp[i]=tmp[i].substr(1);
j=this.tab_nb_char;
j=t.tab_nb_char;
}else if(tmp[i].charAt(0)==" ")
tmp[i]=tmp[i].substr(1);
}
@ -308,40 +411,42 @@
insText+="\n";
}
//insText+="_";
this.textarea.value = startText + insText + endText;
pos_start = start;
pos_end= this.textarea.value.indexOf("\n", startText.length + insText.length);
a.value = startText + insText + endText;
pos_start = start;
pos_end = a.value.indexOf("\n", startText.length + insText.length);
if(pos_end==-1)
pos_end=this.textarea.value.length;
pos_end=a.value.length;
//pos = start + repdeb.length + insText.length + ;
}
this.textarea.selectionStart = pos_start;
this.textarea.selectionEnd = pos_end;
a.selectionStart = pos_start;
a.selectionEnd = pos_end;
//if( document.selection ){
if(this.nav['isIE']){
if(t.isIE){
// select the text for IE
this.setIESelection();
t.setIESelection();
setTimeout("editArea.is_tabbing=false;", 100); // IE can accept to make 2 tabulation without a little break between both
}else
this.is_tabbing=false;
t.is_tabbing=false;
};
EditArea.prototype.press_enter= function(){
if(!this.smooth_selection)
return false;
if(this.nav['isIE'])
this.getIESelection();
this.getIESelection();
var scrollTop= this.result.scrollTop;
var scrollLeft= this.result.scrollLeft;
var start=this.textarea.selectionStart;
var end= this.textarea.selectionEnd;
var start_last_line= Math.max(0 , this.textarea.value.substring(0, start).lastIndexOf("\n") + 1 );
var begin_line= this.textarea.value.substring(start_last_line, start).replace(/^([ \t]*).*/gm, "$1");
var lineStart = this.textarea.value.substring(0, start).split("\n").length;
if(begin_line=="\n" || begin_line=="\r" || begin_line.length==0)
{
return false;
}
if(this.nav['isIE'] || this.nav['isOpera']){
if(this.isIE || ( this.isOpera && this.isOpera < 9.6 ) ){
begin_line="\r\n"+ begin_line;
}else{
begin_line="\n"+ begin_line;
@ -351,9 +456,9 @@
this.area_select(start+ begin_line.length ,0);
// during this process IE scroll back to the top of the textarea
if(this.nav['isIE']){
this.result.scrollTop= scrollTop;
this.result.scrollLeft= scrollLeft;
if(this.isIE){
this.result.scrollTop = scrollTop;
this.result.scrollLeft = scrollLeft;
}
return true;
@ -398,54 +503,106 @@
else
line= infos["full_text"].substr(0, endLastLine).split("\n").length + 1;
var curPos= end - endLastLine;
this.displayToCursorPosition("end_bracket", line, curPos, infos["full_text"].substring(endLastLine +1, end));
var curPos= end - endLastLine - 1;
var endLineLength = infos["full_text"].substring(end).split("\n")[0].length;
this.displayToCursorPosition("end_bracket", line, curPos, infos["full_text"].substring(endLastLine +1, end + endLineLength));
return true;
};
EditArea.prototype.displayToCursorPosition= function(id, start_line, cur_pos, lineContent, no_real_move){
var elem= $("test_font_size");
var dest= $(id);
var postLeft=0;
elem.innerHTML="<pre><span id='test_font_size_inner'>"+lineContent.substr(0, cur_pos).replace(/&/g,"&amp;").replace(/</g,"&lt;")+"</span></pre>";
posLeft= 45 + $('test_font_size_inner').offsetWidth;
var elem,dest,content,posLeft=0,posTop,fixPadding,topOffset,endElem;
var posTop=this.lineHeight * (start_line-1);
elem = this.test_font_size;
dest = _$(id);
content = "<span id='test_font_size_inner'>"+lineContent.substr(0, cur_pos).replace(/&/g,"&amp;").replace(/</g,"&lt;")+"</span><span id='endTestFont'>"+lineContent.substr(cur_pos).replace(/&/g,"&amp;").replace(/</g,"&lt;")+"</span>";
if( this.isIE || ( this.isOpera && this.isOpera < 9.6 ) ) {
elem.innerHTML= "<pre>" + content.replace(/^\r?\n/, "<br>") + "</pre>";
} else {
elem.innerHTML= content;
}
endElem = _$('endTestFont');
topOffset = endElem.offsetTop;
fixPadding = parseInt( this.content_highlight.style.paddingLeft.replace("px", "") );
posLeft = 45 + endElem.offsetLeft + ( !isNaN( fixPadding ) && topOffset > 0 ? fixPadding : 0 );
posTop = this.getLinePosTop( start_line ) + topOffset;// + Math.floor( ( endElem.offsetHeight - 1 ) / this.lineHeight ) * this.lineHeight;
// detect the case where the span start on a line but has no display on it
if( this.isIE && cur_pos > 0 && endElem.offsetLeft == 0 )
{
posTop += this.lineHeight;
}
if(no_real_move!=true){ // when the cursor is hidden no need to move him
dest.style.top=posTop+"px";
dest.style.left=posLeft+"px";
dest.style.left=posLeft+"px";
}
// usefull for smarter scroll
dest.cursor_top=posTop;
dest.cursor_left=posLeft;
// $(id).style.marginLeft=posLeft+"px";
dest.cursor_left=posLeft;
// _$(id).style.marginLeft=posLeft+"px";
};
EditArea.prototype.getLinePosTop= function(start_line){
var elem= _$('line_'+ start_line), posTop=0;
if( elem )
posTop = elem.offsetTop;
else
posTop = this.lineHeight * (start_line-1);
return posTop;
};
// return the dislpayed height of a text (take word-wrap into account)
EditArea.prototype.getTextHeight= function(text){
var t=this,elem,height;
elem = t.test_font_size;
content = text.replace(/&/g,"&amp;").replace(/</g,"&lt;");
if( t.isIE || ( this.isOpera && this.isOpera < 9.6 ) ) {
elem.innerHTML= "<pre>" + content.replace(/^\r?\n/, "<br>") + "</pre>";
} else {
elem.innerHTML= content;
}
height = elem.offsetHeight;
height = Math.max( 1, Math.floor( elem.offsetHeight / this.lineHeight ) ) * this.lineHeight;
return height;
};
/**
* Fix line height for the given lines
* @param Integer linestart
* @param Integer lineEnd End line or -1 to cover all lines
*/
EditArea.prototype.fixLinesHeight= function( textValue, lineStart,lineEnd ){
var aText = textValue.split("\n");
if( lineEnd == -1 )
lineEnd = aText.length-1;
for( var i = Math.max(0, lineStart); i <= lineEnd; i++ )
{
if( elem = _$('line_'+ ( i+1 ) ) )
{
elem.style.height= typeof( aText[i] ) != "undefined" ? this.getTextHeight( aText[i] )+"px" : this.lineHeight;
}
}
};
EditArea.prototype.area_select= function(start, length){
this.textarea.focus();
start= Math.max(0, Math.min(this.textarea.value.length, start));
end= Math.max(start, Math.min(this.textarea.value.length, start+length));
start = Math.max(0, Math.min(this.textarea.value.length, start));
end = Math.max(start, Math.min(this.textarea.value.length, start+length));
if(this.nav['isIE']){
this.textarea.selectionStart = start;
this.textarea.selectionEnd = end;
if(this.isIE)
{
this.textarea.selectionStart = start;
this.textarea.selectionEnd = end;
this.setIESelection();
}else{
if(this.nav['isOpera']){ // Opera bug when moving selection start and selection end
/*this.textarea.selectionEnd = 1;
this.textarea.selectionStart = 0;
this.textarea.selectionEnd = 1;
this.textarea.selectionStart = 0;
this.textarea.selectionEnd = 0;
this.textarea.selectionStart = 0;
this.textarea.selectionEnd = 0;
this.textarea.selectionStart = 0;*/
}
else
{
// Opera bug when moving selection start and selection end
if(this.isOpera && this.isOpera < 9.6 )
{
this.textarea.setSelectionRange(0, 0);
}
this.textarea.setSelectionRange(start, end);
@ -463,4 +620,4 @@
text= this.textarea.value.substring(this.textarea.selectionStart, this.textarea.selectionEnd);
}
return text;
};
};

View file

@ -0,0 +1,12 @@
/*
* Bulgarian translation
* Author: Valentin Hristov
* Company: SOFTKIT Bulgarian
* Site: http://www.softkit-bg.com
*/
editArea.add_lang("bg",{
charmap_but: "Виртуална клавиатура",
charmap_title: "Виртуална клавиатура",
charmap_choose_block: "избери езиков блок",
charmap_insert:"постави този символ"
});

View file

@ -0,0 +1,6 @@
editArea.add_lang("zh",{
charmap_but: "软键盘",
charmap_title: "软键盘",
charmap_choose_block: "选择一个语言块",
charmap_insert:"插入此字符"
});

View file

@ -0,0 +1,10 @@
/*
* Bulgarian translation
* Author: Valentin Hristov
* Company: SOFTKIT Bulgarian
* Site: http://www.softkit-bg.com
*/
editArea.add_lang("bg",{
test_select: "избери таг",
test_but: "тествай копието"
});

View file

@ -0,0 +1,4 @@
editArea.add_lang("zh",{
test_select: "选择标签",
test_but: "测试按钮"
});

View file

@ -17,16 +17,16 @@
EditAreaLoader.prototype.get_escaped_regexp= function(str){
return str.replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g, "\\$1");
return str.toString().replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g, "\\$1");
};
EditAreaLoader.prototype.init_syntax_regexp= function(){
var lang_style= new Object();
var lang_style= {};
for(var lang in this.load_syntax){
if(!this.syntax[lang]) // init the regexp if not already initialized
{
this.syntax[lang]= new Object();
this.syntax[lang]["keywords_reg_exp"]= new Object();
this.syntax[lang]= {};
this.syntax[lang]["keywords_reg_exp"]= {};
this.keywords_reg_exp_nb=0;
if(this.load_syntax[lang]['KEYWORDS']){
@ -70,24 +70,26 @@
// /(("(\\"|[^"])*"?)|('(\\'|[^'])*'?)|(//(.|\r|\t)*\n)|(/\*(.|\n|\r|\t)*\*/)|(<!--(.|\n|\r|\t)*-->))/gi
var syntax_trace=new Array();
var syntax_trace=[];
// /("(?:[^"\\]*(\\\\)*(\\"?)?)*("|$))/g
this.syntax[lang]["quotes"]=new Object();
var quote_tab= new Array();
this.syntax[lang]["quotes"]={};
var quote_tab= [];
if(this.load_syntax[lang]['QUOTEMARKS']){
for(var i in this.load_syntax[lang]['QUOTEMARKS']){
if(typeof(this.load_syntax[lang]['QUOTEMARKS'][i])=="function") continue;
var x=this.get_escaped_regexp(this.load_syntax[lang]['QUOTEMARKS'][i]);
this.syntax[lang]["quotes"][x]=x;
//quote_tab[quote_tab.length]="("+x+"(?:\\\\"+x+"|[^"+x+"])*("+x+"|$))";
quote_tab[quote_tab.length]="("+x+"(?:[^"+x+"\\\\]*(\\\\\\\\)*(\\\\"+x+"?)?)*("+x+"|$))";
//previous working : quote_tab[quote_tab.length]="("+x+"(?:[^"+x+"\\\\]*(\\\\\\\\)*(\\\\"+x+"?)?)*("+x+"|$))";
quote_tab[quote_tab.length]="("+ x +"(\\\\.|[^"+ x +"])*(?:"+ x +"|$))";
syntax_trace.push(x);
}
}
this.syntax[lang]["comments"]=new Object();
this.syntax[lang]["comments"]={};
if(this.load_syntax[lang]['COMMENT_SINGLE']){
for(var i in this.load_syntax[lang]['COMMENT_SINGLE']){
if(typeof(this.load_syntax[lang]['COMMENT_SINGLE'][i])=="function") continue;
@ -116,27 +118,27 @@
this.syntax[lang]["syntax_trace_regexp"]= new RegExp("((.|\n)*?)(\\\\*("+ syntax_trace.join("|") +"|$))", "gmi");
if(this.load_syntax[lang]['SCRIPT_DELIMITERS']){
this.syntax[lang]["script_delimiters"]= new Object();
this.syntax[lang]["script_delimiters"]= {};
for(var i in this.load_syntax[lang]['SCRIPT_DELIMITERS']){
if(typeof(this.load_syntax[lang]['SCRIPT_DELIMITERS'][i])=="function") continue;
this.syntax[lang]["script_delimiters"][i]= this.load_syntax[lang]['SCRIPT_DELIMITERS'];
}
}
this.syntax[lang]["custom_regexp"]= new Object();
this.syntax[lang]["custom_regexp"]= {};
if(this.load_syntax[lang]['REGEXPS']){
for(var i in this.load_syntax[lang]['REGEXPS']){
if(typeof(this.load_syntax[lang]['REGEXPS'][i])=="function") continue;
var val= this.load_syntax[lang]['REGEXPS'][i];
if(!this.syntax[lang]["custom_regexp"][val['execute']])
this.syntax[lang]["custom_regexp"][val['execute']]= new Object();
this.syntax[lang]["custom_regexp"][val['execute']]= {};
this.syntax[lang]["custom_regexp"][val['execute']][i]={'regexp' : new RegExp(val['search'], val['modifiers'])
, 'class' : val['class']};
}
}
if(this.load_syntax[lang]['STYLES']){
lang_style[lang]= new Object();
lang_style[lang]= {};
for(var i in this.load_syntax[lang]['STYLES']){
if(typeof(this.load_syntax[lang]['STYLES'][i])=="function") continue;
if(typeof(this.load_syntax[lang]['STYLES'][i]) != "string"){

View file

@ -1,4 +1,4 @@
editAreaLoader.load_syntax["brainfuck"] = {
editAreaLoader.load_syntax["bf"] = {
'COMMENT_SINGLE' : {}
,'COMMENT_MULTI' : {}
,'QUOTEMARKS' : {}

View file

@ -0,0 +1,56 @@
editAreaLoader.load_syntax["java"] = {
'COMMENT_SINGLE': { 1: '//', 2: '@' }
, 'COMMENT_MULTI': { '/*': '*/' }
, 'QUOTEMARKS': { 1: "'", 2: '"' }
, 'KEYWORD_CASE_SENSITIVE': true
, 'KEYWORDS': {
'constants': [
'null', 'false', 'true'
]
, 'types': [
'String', 'int', 'short', 'long', 'char', 'double', 'byte',
'float', 'static', 'void', 'private', 'boolean', 'protected',
'public', 'const', 'class', 'final', 'abstract', 'volatile',
'enum', 'transient', 'interface'
]
, 'statements': [
'this', 'extends', 'if', 'do', 'while', 'try', 'catch', 'finally',
'throw', 'throws', 'else', 'for', 'switch', 'continue', 'implements',
'break', 'case', 'default', 'goto'
]
, 'keywords': [
'new', 'return', 'import', 'native', 'super', 'package', 'assert', 'synchronized',
'instanceof', 'strictfp'
]
}
, 'OPERATORS': [
'+', '-', '/', '*', '=', '<', '>', '%', '!', '?', ':', '&'
]
, 'DELIMITERS': [
'(', ')', '[', ']', '{', '}'
]
, 'REGEXPS': {
'precompiler': {
'search': '()(#[^\r\n]*)()'
, 'class': 'precompiler'
, 'modifiers': 'g'
, 'execute': 'before'
}
}
, 'STYLES': {
'COMMENTS': 'color: #AAAAAA;'
, 'QUOTESMARKS': 'color: #6381F8;'
, 'KEYWORDS': {
'constants': 'color: #EE0000;'
, 'types': 'color: #0000EE;'
, 'statements': 'color: #60CA00;'
, 'keywords': 'color: #48BDDF;'
}
, 'OPERATORS': 'color: #FF00FF;'
, 'DELIMITERS': 'color: #0038E1;'
, 'REGEXPS': {
'precompiler': 'color: #009900;'
, 'precompilerstring': 'color: #994400;'
}
}
};

View file

@ -26,33 +26,35 @@
// determine if the selected text if a comment or a quoted text
EditArea.prototype.comment_or_quote= function(){
var new_class="";
var close_tag="";
for(var i in parent.editAreaLoader.syntax[editArea.current_code_lang]["quotes"]){
if(EditArea.prototype.comment_or_quote.arguments[0].indexOf(i)==0){
var new_class="", close_tag="", sy, arg, i;
sy = parent.editAreaLoader.syntax[editArea.current_code_lang];
arg = EditArea.prototype.comment_or_quote.arguments[0];
for( i in sy["quotes"] ){
if(arg.indexOf(i)==0){
new_class="quotesmarks";
close_tag=parent.editAreaLoader.syntax[editArea.current_code_lang]["quotes"][i];
close_tag=sy["quotes"][i];
}
}
if(new_class.length==0)
{
for(var i in parent.editAreaLoader.syntax[editArea.current_code_lang]["comments"]){
if(EditArea.prototype.comment_or_quote.arguments[0].indexOf(i)==0){
for(var i in sy["comments"]){
if( arg.indexOf(i)==0 ){
new_class="comments";
close_tag=parent.editAreaLoader.syntax[editArea.current_code_lang]["comments"][i];
close_tag=sy["comments"][i];
}
}
}
// for single line comment the \n must not be included in the span tags
if(close_tag=="\n"){
return "µ__"+ new_class +"__µ"+EditArea.prototype.comment_or_quote.arguments[0].replace(/(\r?\n)?$/m, "µ_END_µ$1");
return "µ__"+ new_class +"__µ"+ arg.replace(/(\r?\n)?$/m, "µ_END_µ$1");
}else{
// the closing tag must be set only if the comment or quotes is closed
reg= new RegExp(parent.editAreaLoader.get_escaped_regexp(close_tag)+"$", "m");
if(EditArea.prototype.comment_or_quote.arguments[0].search(reg)!=-1)
return "µ__"+ new_class +"__µ"+EditArea.prototype.comment_or_quote.arguments[0]+"µ_END_µ";
if( arg.search(reg)!=-1 )
return "µ__"+ new_class +"__µ"+ arg +"µ_END_µ";
else
return "µ__"+ new_class +"__µ"+EditArea.prototype.comment_or_quote.arguments[0];
return "µ__"+ new_class +"__µ"+ arg;
}
};
@ -76,7 +78,7 @@
EditArea.prototype.colorize_text= function(text){
//text="<div id='result' class='area' style='position: relative; z-index: 4; height: 500px; overflow: scroll;border: solid black 1px;'> ";
/*
if(this.nav['isOpera']){
if(this.isOpera){
// opera can't use pre element tabulation cause a tab=6 chars in the textarea and 8 chars in the pre
text= this.replace_tab(text);
}*/
@ -93,41 +95,43 @@
};
EditArea.prototype.apply_syntax= function(text, lang){
var sy;
this.current_code_lang=lang;
if(!parent.editAreaLoader.syntax[lang])
return text;
if(parent.editAreaLoader.syntax[lang]["custom_regexp"]['before']){
for( var i in parent.editAreaLoader.syntax[lang]["custom_regexp"]['before']){
var convert="$1µ__"+ parent.editAreaLoader.syntax[lang]["custom_regexp"]['before'][i]['class'] +"__µ$2µ_END_µ$3";
text= text.replace(parent.editAreaLoader.syntax[lang]["custom_regexp"]['before'][i]['regexp'], convert);
sy = parent.editAreaLoader.syntax[lang];
if(sy["custom_regexp"]['before']){
for( var i in sy["custom_regexp"]['before']){
var convert="$1µ__"+ sy["custom_regexp"]['before'][i]['class'] +"__µ$2µ_END_µ$3";
text= text.replace(sy["custom_regexp"]['before'][i]['regexp'], convert);
}
}
if(parent.editAreaLoader.syntax[lang]["comment_or_quote_reg_exp"]){
//setTimeout("$('debug_area').value=editArea.comment_or_quote_reg_exp;", 500);
text= text.replace(parent.editAreaLoader.syntax[lang]["comment_or_quote_reg_exp"], this.comment_or_quote);
if(sy["comment_or_quote_reg_exp"]){
//setTimeout("_$('debug_area').value=editArea.comment_or_quote_reg_exp;", 500);
text= text.replace(sy["comment_or_quote_reg_exp"], this.comment_or_quote);
}
if(parent.editAreaLoader.syntax[lang]["keywords_reg_exp"]){
for(var i in parent.editAreaLoader.syntax[lang]["keywords_reg_exp"]){
text= text.replace(parent.editAreaLoader.syntax[lang]["keywords_reg_exp"][i], 'µ__'+i+'__µ$2µ_END_µ');
if(sy["keywords_reg_exp"]){
for(var i in sy["keywords_reg_exp"]){
text= text.replace(sy["keywords_reg_exp"][i], 'µ__'+i+'__µ$2µ_END_µ');
}
}
if(parent.editAreaLoader.syntax[lang]["delimiters_reg_exp"]){
text= text.replace(parent.editAreaLoader.syntax[lang]["delimiters_reg_exp"], 'µ__delimiters__µ$1µ_END_µ');
if(sy["delimiters_reg_exp"]){
text= text.replace(sy["delimiters_reg_exp"], 'µ__delimiters__µ$1µ_END_µ');
}
if(parent.editAreaLoader.syntax[lang]["operators_reg_exp"]){
text= text.replace(parent.editAreaLoader.syntax[lang]["operators_reg_exp"], 'µ__operators__µ$1µ_END_µ');
if(sy["operators_reg_exp"]){
text= text.replace(sy["operators_reg_exp"], 'µ__operators__µ$1µ_END_µ');
}
if(parent.editAreaLoader.syntax[lang]["custom_regexp"]['after']){
for( var i in parent.editAreaLoader.syntax[lang]["custom_regexp"]['after']){
var convert="$1µ__"+ parent.editAreaLoader.syntax[lang]["custom_regexp"]['after'][i]['class'] +"__µ$2µ_END_µ$3";
text= text.replace(parent.editAreaLoader.syntax[lang]["custom_regexp"]['after'][i]['regexp'], convert);
if(sy["custom_regexp"]['after']){
for( var i in sy["custom_regexp"]['after']){
var convert="$1µ__"+ sy["custom_regexp"]['after'][i]['class'] +"__µ$2µ_END_µ$3";
text= text.replace(sy["custom_regexp"]['after'][i]['regexp'], convert);
}
}

View file

@ -1,81 +1,72 @@
EditAreaLoader.prototype.start_resize_area= function(){
document.onmouseup= editAreaLoader.end_resize_area;
document.onmousemove= editAreaLoader.resize_area;
var d=document,a,div,width,height,father;
d.onmouseup= editAreaLoader.end_resize_area;
d.onmousemove= editAreaLoader.resize_area;
editAreaLoader.toggle(editAreaLoader.resize["id"]);
var textarea= editAreas[editAreaLoader.resize["id"]]["textarea"];
var div= document.getElementById("edit_area_resize");
a = editAreas[editAreaLoader.resize["id"]]["textarea"];
div = d.getElementById("edit_area_resize");
if(!div){
div= document.createElement("div");
div= d.createElement("div");
div.id="edit_area_resize";
div.style.border="dashed #888888 1px";
}
var width= textarea.offsetWidth -2;
var height= textarea.offsetHeight -2;
/*if(this.nav['isGecko']){
width-=2;
height-=2;
}*/
width = a.offsetWidth -2;
height = a.offsetHeight -2;
div.style.display="block";
div.style.width= width+"px";
div.style.height= height+"px";
var father= textarea.parentNode;
father.insertBefore(div, textarea);
div.style.display = "block";
div.style.width = width+"px";
div.style.height = height+"px";
father= a.parentNode;
father.insertBefore(div, a);
textarea.style.display="none";
a.style.display="none";
editAreaLoader.resize["start_top"]= calculeOffsetTop(div);
editAreaLoader.resize["start_left"]= calculeOffsetLeft(div);
/*var next= textarea.nextSibling;
if(next==null)
father.appendChild(div);
else
father.insertBefore(div, next);*/
editAreaLoader.resize["start_left"]= calculeOffsetLeft(div);
};
EditAreaLoader.prototype.end_resize_area= function(e){
document.onmouseup="";
document.onmousemove="";
var d=document,div,a,width,height;
var div= document.getElementById("edit_area_resize");
var textarea= editAreas[editAreaLoader.resize["id"]]["textarea"];
var width= Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_width"], div.offsetWidth-4);
var height= Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_height"], div.offsetHeight-4);
if(editAreaLoader.nav['isIE']==6){
d.onmouseup="";
d.onmousemove="";
div = d.getElementById("edit_area_resize");
a= editAreas[editAreaLoader.resize["id"]]["textarea"];
width = Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_width"], div.offsetWidth-4);
height = Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_height"], div.offsetHeight-4);
if(editAreaLoader.isIE==6){
width-=2;
height-=2;
}
textarea.style.width= width+"px";
textarea.style.height= height+"px";
div.style.display="none";
textarea.style.display="inline";
textarea.selectionStart= editAreaLoader.resize["selectionStart"];
textarea.selectionEnd= editAreaLoader.resize["selectionEnd"];
a.style.width = width+"px";
a.style.height = height+"px";
div.style.display = "none";
a.style.display = "inline";
a.selectionStart = editAreaLoader.resize["selectionStart"];
a.selectionEnd = editAreaLoader.resize["selectionEnd"];
editAreaLoader.toggle(editAreaLoader.resize["id"]);
return false;
};
EditAreaLoader.prototype.resize_area= function(e){
var allow= editAreas[editAreaLoader.resize["id"]]["settings"]["allow_resize"];
var allow,newHeight,newWidth;
allow = editAreas[editAreaLoader.resize["id"]]["settings"]["allow_resize"];
if(allow=="both" || allow=="y")
{
new_y= getMouseY(e);
var new_height= Math.max(20, new_y- editAreaLoader.resize["start_top"]);
document.getElementById("edit_area_resize").style.height= new_height+"px";
newHeight = Math.max(20, getMouseY(e)- editAreaLoader.resize["start_top"]);
document.getElementById("edit_area_resize").style.height= newHeight+"px";
}
if(allow=="both" || allow=="x")
{
new_x= getMouseX(e);
var new_width= Math.max(20, new_x- editAreaLoader.resize["start_left"]);
document.getElementById("edit_area_resize").style.width= new_width+"px";
newWidth= Math.max(20, getMouseX(e)- editAreaLoader.resize["start_left"]);
document.getElementById("edit_area_resize").style.width= newWidth+"px";
}
//window.status="resize n_w: "+new_width+" new_h: "+new_height+ " new_y: "+new_y+" s_top: "+editAreaLoader.resize["start_top"];
return false;
};

View file

@ -1,19 +1,19 @@
EditArea.prototype.show_search = function(){
if($("area_search_replace").style.visibility=="visible"){
if(_$("area_search_replace").style.visibility=="visible"){
this.hidden_search();
}else{
this.open_inline_popup("area_search_replace");
var text= this.area_get_selection();
var search= text.split("\n")[0];
$("area_search").value= search;
$("area_search").focus();
_$("area_search").value= search;
_$("area_search").focus();
}
};
EditArea.prototype.hidden_search= function(){
/*$("area_search_replace").style.visibility="hidden";
/*_$("area_search_replace").style.visibility="hidden";
this.textarea.focus();
var icon= $("search");
var icon= _$("search");
setAttribute(icon, "class", getAttribute(icon, "class").replace(/ selected/g, "") );*/
this.close_inline_popup("area_search_replace");
};
@ -22,8 +22,8 @@
if(!mode)
mode="search";
$("area_search_msg").innerHTML="";
var search=$("area_search").value;
_$("area_search_msg").innerHTML="";
var search=_$("area_search").value;
this.textarea.focus();
this.textarea.textareaFocused=true;
@ -34,27 +34,27 @@
var pos_begin=-1;
var length=search.length;
if($("area_search_replace").style.visibility!="visible"){
if(_$("area_search_replace").style.visibility!="visible"){
this.show_search();
return;
}
if(search.length==0){
$("area_search_msg").innerHTML=this.get_translation("search_field_empty");
_$("area_search_msg").innerHTML=this.get_translation("search_field_empty");
return;
}
// advance to the next occurence if no text selected
if(mode!="replace" ){
if($("area_search_reg_exp").checked)
if(_$("area_search_reg_exp").checked)
start++;
else
start+= search.length;
}
//search
if($("area_search_reg_exp").checked){
if(_$("area_search_reg_exp").checked){
// regexp search
var opt="m";
if(!$("area_search_match_case").checked)
if(!_$("area_search_match_case").checked)
opt+="i";
var reg= new RegExp(search, opt);
pos= infos["full_text"].substr(start).search(reg);
@ -66,7 +66,7 @@
length=infos["full_text"].match(reg)[0].length;
}
}else{
if($("area_search_match_case").checked){
if(_$("area_search_match_case").checked){
pos= infos["full_text"].indexOf(search, start);
pos_begin= infos["full_text"].indexOf(search);
}else{
@ -77,21 +77,21 @@
// interpret result
if(pos==-1 && pos_begin==-1){
$("area_search_msg").innerHTML="<strong>"+search+"</strong> "+this.get_translation("not_found");
_$("area_search_msg").innerHTML="<strong>"+search+"</strong> "+this.get_translation("not_found");
return;
}else if(pos==-1 && pos_begin != -1){
begin= pos_begin;
$("area_search_msg").innerHTML=this.get_translation("restart_search_at_begin");
_$("area_search_msg").innerHTML=this.get_translation("restart_search_at_begin");
}else
begin= pos;
//$("area_search_msg").innerHTML+="<strong>"+search+"</strong> found at "+begin+" strat at "+start+" pos "+pos+" curs"+ infos["indexOfCursor"]+".";
//_$("area_search_msg").innerHTML+="<strong>"+search+"</strong> found at "+begin+" strat at "+start+" pos "+pos+" curs"+ infos["indexOfCursor"]+".";
if(mode=="replace" && pos==infos["indexOfCursor"]){
var replace= $("area_replace").value;
var replace= _$("area_replace").value;
var new_text="";
if($("area_search_reg_exp").checked){
if(_$("area_search_reg_exp").checked){
var opt="m";
if(!$("area_search_match_case").checked)
if(!_$("area_search_match_case").checked)
opt+="i";
var reg= new RegExp(search, opt);
new_text= infos["full_text"].substr(0, begin) + infos["full_text"].substr(start).replace(reg, replace);
@ -114,25 +114,25 @@
EditArea.prototype.area_replace_all= function(){
/* this.area_select(0, 0);
$("area_search_msg").innerHTML="";
while($("area_search_msg").innerHTML==""){
_$("area_search_msg").innerHTML="";
while(_$("area_search_msg").innerHTML==""){
this.area_replace();
}*/
var base_text= this.textarea.value;
var search= $("area_search").value;
var replace= $("area_replace").value;
var search= _$("area_search").value;
var replace= _$("area_replace").value;
if(search.length==0){
$("area_search_msg").innerHTML=this.get_translation("search_field_empty");
_$("area_search_msg").innerHTML=this.get_translation("search_field_empty");
return ;
}
var new_text="";
var nb_change=0;
if($("area_search_reg_exp").checked){
if(_$("area_search_reg_exp").checked){
// regExp
var opt="mg";
if(!$("area_search_match_case").checked)
if(!_$("area_search_match_case").checked)
opt+="i";
var reg= new RegExp(search, opt);
nb_change= infos["full_text"].match(reg).length;
@ -140,7 +140,7 @@
}else{
if($("area_search_match_case").checked){
if(_$("area_search_match_case").checked){
var tmp_tab=base_text.split(search);
nb_change= tmp_tab.length -1 ;
new_text= tmp_tab.join(replace);
@ -161,10 +161,10 @@
}
}
if(new_text==base_text){
$("area_search_msg").innerHTML="<strong>"+search+"</strong> "+this.get_translation("not_found");
_$("area_search_msg").innerHTML="<strong>"+search+"</strong> "+this.get_translation("not_found");
}else{
this.textarea.value= new_text;
$("area_search_msg").innerHTML="<strong>"+nb_change+"</strong> "+this.get_translation("occurrence_replaced");
_$("area_search_msg").innerHTML="<strong>"+nb_change+"</strong> "+this.get_translation("occurrence_replaced");
// firefox and opera doesn't manage with the focus if it's done directly
//editArea.textarea.focus();editArea.textarea.textareaFocused=true;
setTimeout("editArea.textarea.focus();editArea.textarea.textareaFocused=true;", 100);

View file

@ -4,6 +4,7 @@
<head>
<title>EditArea</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
[__CSSRULES__]
[__JSCODE__]
</head>
@ -20,6 +21,7 @@
<div id='line_number' selec='none'></div>
<div id='content_highlight'></div>
<div id='test_font_size'></div>
<div id='selection_field_text'></div>
<textarea id='textarea' wrap='off' onchange='editArea.execCommand("onchange");' onfocus='javascript:editArea.textareaFocused=true;' onblur='javascript:editArea.textareaFocused=false;'>
</textarea>
@ -91,9 +93,8 @@
{$accesskey} E: {$toggle}<br />
<br />
<em>{$about_notice}</em>
<br /><div class='copyright'>&copy; Christophe Dolivet - 2007</div>
<br /><div class='copyright'>&copy; Christophe Dolivet 2007-2009</div>
</div>
</div>
</div>
</body>
</html>

View file

@ -11,6 +11,7 @@
,start_highlight: true // if start with highlight
,allow_resize: "both"
,allow_toggle: true
,word_wrap: true
,language: "en"
,syntax: "php"
});
@ -22,7 +23,7 @@
,language: "en"
,syntax: "html"
,toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"
,syntax_selection_allow: "css,html,js,php,python,vb,xml,c,cpp,sql,basic,pas"
,syntax_selection_allow: "css,html,js,php,python,vb,xml,c,cpp,sql,basic,pas,brainfuck"
,is_multi_files: true
,EA_load_callback: "editAreaLoaded"
,show_line_colors: true
@ -122,21 +123,22 @@
<body>
<h2>EditArea examples</h2>
<p>Retrieve EditArea on <a href='http://sourceforge.net/projects/editarea'>sourceforge</a> or on
my personal <a href='http://www.cdolivet.net/index.php?page=editArea'>website</a>.
my personal <a href='http://www.cdolivet.com/index.php?page=editArea'>website</a>.
</p>
<form action='' method='post'>
<fieldset>
<legend>Example 1</legend>
<p>Test in English with php syntax, highlighted, toggle enabled, resize enabled and default toolbar. Also offer the possibility to switch on/off the readonly mode.</p>
<p>Test in English with php syntax, highlighted, toggle enabled, word-wrap enabled, resize enabled and default toolbar. Also offer the possibility to switch on/off the readonly mode.</p>
<textarea id="example_1" style="height: 350px; width: 100%;" name="test_1">
<?php
$authors= array();
$news= array();
$query="SELECT author, COUNT(id) as 'nb_news' FROM news_messages GROUP BY author";
$result=mysql_query($query, $DBnews);
while($line = mysql_fetch_assoc($result)){
$authors[$line["author"]]= $line["author"];
$news[$line["author"]]=$line['nb_news'];
$authors = array();
$news = array();
/* this is a long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long comment for showing word-wrap feature */
$query = "SELECT author, COUNT(id) as 'nb_news' FROM news_messages GROUP BY author";
$result = mysql_query($query, $DBnews);
while( $line = mysql_fetch_assoc($result) ){
$authors[$line["author"]] = $line["author"];
$news[$line["author"]] = $line['nb_news'];
}
$list= sprintf("('%s')", implode("', '", $authors));

View file

@ -0,0 +1,10 @@
Copyright (c) 2008, Christophe Dolivet
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of EditArea nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,10 @@
Index: www/extras/editarea/edit_area/reg_syntax/brainfuck.js
===================================================================
--- www/extras/editarea/edit_area/reg_syntax/brainfuck.js (revision 10612)
+++ www/extras/editarea/edit_area/reg_syntax/brainfuck.js (working copy)
@@ -1,4 +1,4 @@
-editAreaLoader.load_syntax["brainfuck"] = {
+editAreaLoader.load_syntax["bf"] = {
'COMMENT_SINGLE' : {}
,'COMMENT_MULTI' : {}
,'QUOTEMARKS' : {}

View file

@ -12,7 +12,10 @@ DONE:
- enable it for ctrl+space in the middle of a word
/***** To do Needed *****/
- Internet explorer: adding a caracter one the longest line as for consequence to make a scrollLeft=0 (in non wrapped mode)
- Do optimisation for trying to only update the changed line in content_highlight
- add real IE8 support (fix the tabulation width bug in IE8 that has now always the same width no matter the font-size and font-family in textarea but not in <pre>...)
- change_callback is called one time at the beginning event if the text has not changed
- check later init call with safari 3
- improve callback documentation.
@ -20,19 +23,19 @@ DONE:
/***** To do Optionnal*****/
- possibility to switch on/off line numbers (allow to get more space)
- remove the bottom scrollbar is there is no neeed to get one. (adjust the width to the real content width).
- amelioration of the scroll_to_view function for when there is several lines selected (center a little more the selected text)
- darken background of the selection when syntax highlight is on (not easy to see actually under firefox)
- improve opera 9 compatibility (very hard, need help for workaround) cf "Browser remarks".
- optimize scroll_to_view for Opera?
- add word wrap option (nearly impossible, there is too much lacks of support from browsers, have spend more than 6 hours on this)
- add word wrap option for opera (bug with rendering mode of pre-wrap
- possibility to add larger font sizes as options?
/*** Bugs ***/
- firefox: when using verdana (or other non-monospace fonts) switching the font size after font load has as results to sometimes give different render in textarea and in content_highlight (espacially near 11 and 12pt)
- opera: (bloc word-wrap on opera) bug with cursor_end ()[] for a wrapped line (has wrong offsetLeft if rendered as multiline)
- opera: (bloc word-wrap on opera) bug if first wraped character follow a <span> (or similar) on wrapped lines
- when pressing "reset highlight" in IE the textarea scroll to the top (don't know how to fix this...)
- when pressing "shift+page down" and then "shift+page up" the top of the selection move where as it should be to the bottom of the selection to move (to fix it: must know in which direction the selection grow in "get_selection_infos")
- Editor doesnt load when running on ASP.NET when using codebehind declaration at top of page (don't really know what to do because I don't know ASP nor .NET)
- (still pending?) when pressing "shift+page down" and then "shift+page up" the top of the selection move where as it should be to the bottom of the selection to move (to fix it: must know in which direction the selection grow in "get_selection_infos")
/*** Problems ***/
@ -48,28 +51,14 @@ DONE:
- editarea must be always visible, to hide it use the hide() function
/*** Compatibility ***/
Supported browsers:
Firefox 1.5 & 2
IE 6 & 7
Opera 9
Safari 3.1
No more supported:
Netscape 8 with rendering mode IE
Mozilla 1.7 (buggy)
/*** Browser remarks/bugs ***/
OPERA:
- opera bug or spec problem: find how to get the textarea content width
- opera bug: pressing the " key is equals to pressing the scrolldown key (with french keyboard at least)
- currently disabled: scrollDown/Up function (due to the " key error)
- opera is very very slow with syntax highlight (regexp)
- opera doesn't render tabulation of the same width in a textarea as in a <pre> tag... => doesn't allow to use non monospace font
- opera doesn't manage correctly the width 100% for the iframe and allow to scroll with position absolute
- opera bug: pressing the " key is equals to pressing the scrolldown key (with french keyboard at least) (still in opera 9.6?)
- currently disabled: scrollDown/Up function (due to the " key error) (still in oera 9.6?)
- opera is very very slow with syntax highlight (regexp) (still in oera 9.6?)
- opera doesn't manage correctly the width 100% for the iframe
- it's possible to make scroll the window in fullscreen
IE:
- IE is far slower than firefox in highlight mode due to opacity filter
@ -80,6 +69,3 @@ FIREFOX:
- the scrollHeight value for the textarea never decresease when lines are deleted (don't remember anything about this)
NETSCAPE:
- can't manage lineHeight for textarea in firefox mode
- setting highlight mode on crash the navigator with no warning in firefox mode