Probably not possible but .... Textarea multiple font colors

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Probably not possible but .... Textarea multiple font colors

Post by Chris Corbyn »

Hi,

Would anybody know if it's possible to highlight words within a textarea on a web page? Not sure you can specify font colors for just certain words... just the whole font in the textarea I belive?

Thanks
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

what you are saying is possible with richtextedit control on windows side.
if you are developing for Win side maybe you can use that.

AFAIK. there isn't any way for selective formatting inside textarea. :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there are cross browser/platform rich-text editors though that integrate into pages quite well.. hoteditor.com I believe has one..
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

That looks promising...
does that help you d11wtq :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That's brilliant thanks.... I'll take a look (gonna work on a PHP editting app for integration with a simple filemanager... string highlihgting, function highlighting and the likes).... I'll see how it goes, it may all fall through once I start it.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

HTMLArea is another rich text editor you can use as a replacement for a text area.

http://www.kevinroth.com/rte/demo.htm is another
Last edited by CoderGoblin on Wed Feb 09, 2005 8:26 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

CoderGoblin wrote:http://www.kevinroth.com/rte/demo.htm is another
I have just integrated this one into a CMS i am developing....it is very good with a small file size.

Thanks for the heads up

Mark
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Thanks for that.... the hoteditor one that feyd posted has the JS protected and it all need unescaping to read it... this is nicer cheers. It's not your coding is it?

I might change it to remove the buttons etc and just automate syntax highlighting like Dreamweaver or the brilliant freeware Crimson Editor would do.

Good stuff :P
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

d11wtq wrote:It's not your coding is it?

I might change it to remove the buttons etc and just automate syntax highlighting like Dreamweaver or the brilliant freeware Crimson Editor would do.
If you are talking about the kevinroth demo it is not my code (although it initially took me a long time to find it :wink:) The reduction of the options is fairly easy to do within the javascript, with the additional advantage is that you can remove redundant code and therfore shrink the filesize accordingly.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yeah I just took out all the chunk of code with the buttons in.... I don't want any options for the user to change font colors themselves etc.... i want the colors to just change if the string matches a function from an array of functions and so on and so forth.... I'm at work at the moment but I'll have a good play with it later.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Ive just been studying the JS of the Kevin Roth code and it looks pretty simple to remove any or all the user available formatting buttons.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yeah thanks I had done it already... I just need to see what the other functions do so I can remove the stuff I don't need... all I need are the one's to set font colors and create bold text... haven't even looked how it's done yet, I need time to sit and look at it properly.

The basic idea is to have several plain text files, one for functions, one for PHP syntax and anything else I need. Then These are used to build some arrays... onKeyup or whever the text box is checked for any words that match the value of a function or whatever and if so, the string is colored automatically. Sounds simple but I'm sure i'll trip up. I'll also need to validate whether or not a string has been unquoted etc and brackets are closed or open. The last thing I'll be doing is automatically creating tabs for nested blocks of code... I'll put the code up in snippets when it's done
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

WARNING: Be aware that the colour tags (HTML tags) are hidden from the user and may potentially be deleted accidently in kevinroth's code.

Thought I'd highlight this now as I have run into problems with it before.
Post Reply