473,387 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Syntax highlighting in TEXTAREA - possible?

Nic

Hi - I am battling to find the a resource, so maybe some one in here can
help

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. There are millions of resources for just normal
text color and background colors (and images), but nothing on keyword
highlighting.

Any help will be appreciated.

O yes - this is for an Open Source project I am planning

Cheers

Nico

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 22 '05 #1
1 5628


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/
Oct 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jay Davis | last post by:
I use xemacs and syntax highlighting for my IDE, but I'm not a big fan of the default syntax highlighting colors. For instance, in 'def fun():' both 'def' and 'fun' are the same color. I kind of...
9
by: news.microsoft.com | last post by:
Dear all, I have to do a source code editor to implement syntax hilighted with special colors , IntelliSense function. Could anybody give me some tips or links? Thanks,
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
2
by: rockstar_ | last post by:
Hello all- I'm developing a Content Management software for my own site, and possibly package and deploy to other sites (for friends, family, etc.) The content management software is combined...
5
by: Xerxes | last post by:
Hi, I am using the following script (in an AS.NET application) to highlight text fields when they have the focus. Can I extend this to use other form elements such as textareas and dropdowns?...
7
by: u01jmg3 | last post by:
hi, i just wondered if there was a way (like there is in firefox) using javascript to allow a user using IE to drag a hyperlink (without highlighting it) and if dragged over a textarea that the text...
11
by: Christoph Burschka | last post by:
Are there any free PHP libraries/utility functions that can color the syntax of various programming languages (eg. Java and C++)? I am posting code snippets on my site and would like to know if...
0
by: Scott | last post by:
Hi, I think I may have finally found a IDE/text editor that I like, but, it still haves one problem. Geany haves syntax highlighting, but it is not very good for Python. It only seems to have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.