Syntax Highlighting

Started by
5 comments, last by Cyberdrek 22 years, 5 months ago
Well, it''s been a while since I''ve posted a question on the boards but hey, I''m busy with school. Now, here''s the situation. Being busy at school leaves me almost no time to work on my game and I''m working on a little project that I can carry with me to school and work on in my spare time( my game would be too big to carry with me ). Now, I''m working on a small text editor an I want it to use syntax highlighting if specified by the user, the part I''m having problems is the syntax highlight. I''ve tried parsing the text from the RichTextEdit letter by letter and also, word by word, I''ve tried everything I could think of but never managed to get what I was looking for. I was wondering if anybody here ever coded Syntax Highlighting for an editor and no, I don''t want to use a Library, the point of this project is to get my brains working on the problem so I plan on writing the parser myself but I need help as everything I''ve tried failed. I don''t really need the code itself but rather the main idea on how to implement it, algorithms or any input that I could use as a base to work on. Oh and I''ve also searched in most search engines for tuts on the topic but only fond stuff about how to set the syntax highlighting for most Editors and IDE that support that option. "And that''s the bottom line cause I said so!" Cyberdrek Headhunter Soft A division of DLC Multimedia
Resist Windows XP''s Invasive Production Activation Technology! "gitty up" -- Kramer
[Cyberdrek | ]
Advertisement
I wrote a tool to convert C++ files to syntax highlited HTML files a week ago (yes, I know about the GNU tool that does that, but I wanted to do it on my own ). However, I doubt the code would be applicable to a ''real time'' highliter.

You''ll have to define ''begin'' and ''end'' scan characters (things like: ''('', '')'', '','', '';'', some more complex ones, et cetera). Every time a character is changed, you find the previous ''begin'' character, then rescan what to highlight to the next ''end'' character.

[Resist Windows XP''s Invasive Production Activation Technology!]
quote:Original post by Null and Void
I wrote a tool to convert C++ files to syntax highlited HTML files a week ago (yes, I know about the GNU tool that does that, but I wanted to do it on my own ). However, I doubt the code would be applicable to a ''real time'' highliter.

You''ll have to define ''begin'' and ''end'' scan characters (things like: ''('', '')'', '','', '';'', some more complex ones, et cetera). Every time a character is changed, you find the previous ''begin'' character, then rescan what to highlight to the next ''end'' character.

[Resist Windows XP''s Invasive Production Activation Technology!]


Hey My good old friend Null, Thanks for the input. I had thought about something like that but I''m thinking a bit more of like as soon as the user finished typing a word, it checks the word against a bank of words and if the two match, it highlights the word. Although, I think your method is probably the way to start out... I''ll give that a try for sure. Thank dude.


If anybody else has input I''d really appreciate it.



"And that''s the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
[Cyberdrek | ]
Here's a link about a bloke's struggle to get syntax highlighting. It goes into details about what things he tried, the problems, etc. I think he says he didn't get it completely finished, but there's still quite a bit of good info. The code's in Delphi (Pascal), but he explains everything, so don't let that put you off if you're using C/C++.

Anyway, the link: Some nerd says things.

I've also found a few other links about it, but I'll have to find 'em again. Maybe tomorrow, maybe not. Anyway, good luck. Syntax highlighting is something everyone wants to do, until they find some other fancy (in my case, it was demo effects ).

Alistair Keys

"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne

Edited by - Alimonster on November 16, 2001 7:14:07 PM
quote:Original post by Alimonster
Here''s a link about a bloke''s struggle to get syntax highlighting. It goes into details about what things he tried, the problems, etc. I think he says he didn''t get it completely finished, but there''s still quite a bit of good info. The code''s in Delphi (Pascal), but he explains everything, so don''t let that put you off if you''re using C/C++.

Anyway, the link: Some nerd says things.

I''ve also found a few other links about it, but I''ll have to find ''em again. Maybe tomorrow, maybe not. Anyway, good luck. Syntax highlighting is something everyone wants to do, until they find some other fancy (in my case, it was demo effects ).

Alistair Keys

"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne

Edited by - Alimonster on November 16, 2001 7:14:07 PM


Thanks, I''ll be sure to take a look. Oh and I may have forgotten to mention but I am using Delphi too, even though I would of liked to do it in C/C++, I find that it''s too complicated for nothing when you want to create small tools like my project. So everything is cool.

"And that''s the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
[Cyberdrek | ]
Respect to you for using Delphi! Anyway, if you want a laugh, here's a funny link from the Turbo forum:

Me banging my head against a brick wall

Some people, eh?

I've found another link about syntax highlighting. It's in assembler and seems a bit brute force, so I don't know how useful it will be. Still, scary asm stuff.

Alistair Keys
My web site

"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne

Edited by - Alimonster on November 17, 2001 8:34:14 AM
quote:Original post by Alimonster
I''ve found another link about syntax highlighting. It''s in assembler and seems a bit brute force, so I don''t know how useful it will be. Still, scary asm stuff.


Again, thanks for the info...



"And that''s the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
[Cyberdrek | ]

This topic is closed to new replies.

Advertisement