Go Back   Trackpads Community > General Discussions > Computer and Technology > Web Design

Web Design Forums and discussions on webdesign

Web Design

Reply
 
LinkBack Thread Tools
Old 10-26-2005, 10:04   #1 (permalink)
Dylan Parry
Civilians

 
Default Syntax highlighting in a textarea

Hi folks,

I was wondering whether it is possible to colour some text within a
textarea a different colour than the rest of the text? JavaScript would
be fine for this (and I suspect it is the *only* way to do it client
side) as it's only for bells and whistles.

I ask this because I have a textarea that I am typing XML into and would
like to be able to apply basic syntax highlighting so that the tags
stand out a little more. Has anybody tried to do this?

Cheers,

--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references

Nutritional Information: This post contains no added salt or sugar,
and is the only post proven to actually *lower* your cholesterol.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
Old 10-26-2005, 14:07   #2 (permalink)
GreyWyvern
Civilians

 
Default Re: Syntax highlighting in a textarea

And lo, Dylan Parry didst speak in alt.www.webmaster:

> Hi folks,
>
> I was wondering whether it is possible to colour some text within a
> textarea a different colour than the rest of the text? JavaScript would
> be fine for this (and I suspect it is the *only* way to do it client
> side) as it's only for bells and whistles.
>
> I ask this because I have a textarea that I am typing XML into and would
> like to be able to apply basic syntax highlighting so that the tags
> stand out a little more. Has anybody tried to do this?


It would probably be necessary to "fake it" with a similarily styled
<div>. Allow users to type in a normal textarea, but after each keypress
the results would appear syntax-highlighted up above. It would require
Javascript, and two views of the code at once, but it would work.

Alternatively, if you could jigger a way to show users the location of the
cursor, you could hide the textarea (or at least make it really really
small), while still applying focus to it, so it would appear that the user
was typing directly into the <div>

Grey

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollary that nothing is ridiculous.
- http://www.greywyvern.com/orca#rsear - Orca Search: Full-featured spider
and site-search engine
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-27-2005, 14:03   #3 (permalink)
Toby Inkster
Civilians

 
Default Re: Syntax highlighting in a textarea

Dylan Parry wrote:

> I have a textarea that I am typing XML into and would like to be able
> to apply basic syntax highlighting so that the tags stand out a little
> more.


I would expect that the only way to do this (well) would be to create a
Java/Flash applet to implement the widget for you.

Java would probably be a good choice as it has fairly mature XML support:
you could add more than just syntax highlighting: e.g. automatic closing
tags (type "</" and the editor finishes closing the most recently opened
element for you) and a well-formedness check.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
textarea rows Sig Web Design 6 10-23-2005 18:02
Can you add maxlength to a TEXTAREA field in a form Serg Web Design 1 10-03-2005 22:00
Highlighting Row Mike Microsoft Applications 1 02-08-2005 16:00
HTML Textarea Replacment Jeremy Ross Web Design 3 11-05-2004 16:00
Help with syntax PRDuPont Microsoft Applications 1 06-16-2004 05:47


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 22:36.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.76767 seconds with 19 queries