Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Suggestions on improving syntax highlighting performance? (VB6)

Author
Message
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 1st Jun 2004 12:23
Yesterday I was in a hotel with my family for a 2 day vacation, so I was bored with no net access or games and all I had was the laptop. I got kinda bored so I decided to try out some VB6 experimenting, and came up with a basic syntax highlighter just before we left. Well, it works well and I was kinda proud of it because I didn't have to do it in C or something, but the gist of how it works is it takes the text from a rich text box and parses it for keywords, so it can apply some formatting to keywords and iron out the RTF specific keywords/escape characters or whatever like braces, and convert vbNewLine to "\par " and so on. Then after the formatting I replace the TextRTF of the RTB with the formatted one that was just made, so it shows up nicely with the formatting etc. The problem is that it has to re-parse the entire text everytime the text is changed, so when I did some maniacal copy+pasting until I had 9000+ characters, the app lagged badly every time I changed the text.

Does anybody have suggestions on how to speed up the app? I'm sure this just has to do with the parsing but I don't really know what changes should be made to it.

Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 1st Jun 2004 12:50
Rather then parsing the whole document each time something is done, just parse the line that was changed when the 'enter' key was pressed or the user move s to a new line. This is what VB does itself, you'll notice the syntax highlighting doesn't appear until you go to the next line.


"Computers are useless they can only give you answers."
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 1st Jun 2004 13:00
Got it. I didn't notice GetLineFromChar until I checked the object browser. But it will take more work to find the line number from the RTF text because I still have to parse it. I'll try, thanks.

Login to post a reply

Server time is: 2024-11-25 10:53:20
Your offset time is: 2024-11-25 10:53:20