Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 12th, 2005, 10:07 AM   #1
Yu Raider
Newbie
 
Join Date: Jan 2005
Posts: 11
Rep Power: 0 Yu Raider is on a distinguished road
Syntax coloring

Hi! Is there a tutorial on syntax coloring available?
Yu Raider is offline   Reply With Quote
Old Jan 12th, 2005, 11:09 AM   #2
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
what do you mean? what program are you using? syntax coloring is determined by the program. Vim has a bunch of .vim files that determine what gets what color, and I'm sure other programs have similar methods
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Jan 12th, 2005, 12:29 PM   #3
Ravilj
Programmer
 
Ravilj's Avatar
 
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 5 Ravilj is on a distinguished road
If it is for MS Visual Studio I posted a "how to" on adding your own "words" for syntax highlighting for C++ but I am sure the same would apply to Visual Basic just different directory... worth a look. Just cant remember where i posted it :/
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005!
Ravilj is offline   Reply With Quote
Old Jan 12th, 2005, 12:34 PM   #4
Ravilj
Programmer
 
Ravilj's Avatar
 
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 5 Ravilj is on a distinguished road
found it: http://www.programmingforums.org/for...ead.php?t=1635
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005!
Ravilj is offline   Reply With Quote
Old Jan 12th, 2005, 1:39 PM   #5
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
ah Visual Studio, i always forget to look at what forum we're in..my bad..
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Jan 13th, 2005, 7:19 AM   #6
Yu Raider
Newbie
 
Join Date: Jan 2005
Posts: 11
Rep Power: 0 Yu Raider is on a distinguished road
What I mean is: I am making a GUI editor for a programming language, that's why I need to know how to make a RichText editor color some keywords, like "print" or so.
Yu Raider is offline   Reply With Quote
Old Jan 15th, 2005, 11:14 AM   #7
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Syntax Colouring

OK I know what you're trying to do.
I made a similar thing for writing VBScripts for windows, because I was annoyed that nothing would do it (until Notepad2 came along!)

The way I did it was to have a Rich Text Control in which the user types stuff. When the line that the I-bar is on is changed (i.e. up,down,return is pressed or the user goes beyond the end of the line) that line ONLY is coloured - if you try to re-colour everything every time a key is pressed, it goes really slowly.
Funtions like getcurrentline and getlinecharstart aren't hard to write, you just have to be careful if the word starts at +1 or -1 etc.
Iterate through the edited line, searching for keywords, capitalising and colouring them appropriately. Design your functions carefully - remember, if you wanted to highlight "Or" and capitalize it, you could end up with "FOr" "FOrm" etc.
If you are familiar with the rich text format (a markup language like HTML) you can search for and change the appropriate tokens to apply colour. Otherwise, the slightly slower method is to set SelStart and SelLength appropriately along with the SelColor attribute.
It worked fine for me, as the files I wanted to write with it were going to be no more than a page long, however if you want to write a full-blown IDE then the rich text box control will struggle - you'll probably need to write your own. Then you can go on to autocomplete, parameter info tooltips etc...
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:21 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC