Syntax coloring

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by webmatze.

Hi PureBasic Coders.

I am trying to do a simple code editor with PureBasic, like the one shipped with purebasic, but want to add some more features.

Can anybody give me some hints for using syntax coloring with the Richedit Library? Or is there any other way for doing this?

I also want to display the current column and row of the cursor in the Richedit Gadget. How can I get them?

thanks in advance for every answer!

Registered Purebasic User.
Using Windows XP on an AMD System...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.



The best way to do it is to use the RTF stream. It's rather difficult to do... Anyway, I plan to release the PureBasic editor source code when converted it to PureBasic. In about a month. So you could take it and upgrade it.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

In my opinion, syntax coloring should be managed by the programmer, since each editor I know uses a different syntax highlighting template format. If you take a look to the RichEdit library documentation you'll learn how to do it (it's a huge work, I know).

I don't know how to use the method Fred mentions, but it's probably the faster (he always uses the fastest way :wink:

Bye,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by webmatze.

Thanks for your answers.
I will take a look at the RTF description on MSDN.
May be I have to code my own RTF Library.
The problem is that I never did syntax coloring before so I have to find out how to do it.

Registered Purebasic User.
Using Windows XP on an AMD System...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Basically, you have to parse the line (detect the procedure, the constants etc) and build an RTF equivalent:

If OpenWindow(....)

will give:

{RTF{\c1If\c0 \c2OpenWindow\c0(...)

etc.. Open it in Word to see if the RTF is good :). You can save a simple document in word in RTF format and see how it works.

Bye,

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

a link to RTF-description:

http://www.codemanual.net/main/file_for ... B3%5D.html


Getting better with a little help from my friends....thx Siggi
Post Reply