Nic wrote:
The problem is as follows: I am trying to build a mod_perl source code
editor for the web - to edit Perl source code in a browser. The trick
is that I want to add syntax highlighting
to a HTML TEXTAREA tag.
The HTML 4/XHTML 1 textarea control is a plain text edit control so
there is no way to have some characters or words in that control
highlighted. Some browsers (IE/Win, Mozilla since 1.4, Opera since 8.0)
by now allow script to manipulate the selection in a textarea so there
you can use script to select some text in the textarea.
If you want to build a Perl source code editor with syntax hightlighting
then you need to look into editable HTML elements which some browsers
implement, IE/Win (since IE 5) and Mozilla since 1.4 (and Opera 9.0
Preview 1) allow editable iframes where you can set the designMode
property of the document object to 'on' with script and then the user
can edit the current document in the iframe and script can of course
manipulate that too.
See <http://www.mozilla.org/editor/midas-spec.html> for the Mozilla
documentation on that. msdn.microsoft.com has the specification for IE/Win.
IE 5.5 and later on Windows additionally support editable elements in a
document by setting e.g.
<pre contentEditable="true">
so that way you do not need a complete iframe but can have part of your
document editable.
That way you can do your syntax editor with editable markup and CSS.
--
Martin Honnen
http://JavaScript.FAQTs.com/