G
Guest
Sorry I posted this post earlier but got the name and subject the wrong way round (new to this!) so it perhaps didn't look right
Sorry for that. But please please answer if you know anything about it..
Thanks
I've got a procedure that is responsible for performing the following operations on a richtextbox
1) determining what parts of the text to forma
2) formatting specific ranges of text a specific color
I need to do this whenever the contents of the richtextbox change. The algorithm is quite fast as I have built in some speed saving optimizations, but i need to do some more, I was wondering if anybody could give me any suggestions? So far, I've coded it to
* - retrieve information about all ranges 'as of now' but only setting the format of ones that are new / only unsetting the format of ones that were there but aren't no
* - only set the format of ranges that are visible. For this, I use the message EM_GETFIRSTVISIBLELINE to get the first visible line, and the line count by dividing the height by the height of a line (got by GetTextMetrics). But then I need to do a rescan of ranges to format on vscroll aswell as on textchange, which is a bit bad as it's slow when you scroll
I was thinking of having some sort of 'lazy updater' type thing that either runs for, say, 100 milliseconds each second, or in a different thread, to update the RTB for the ranges that are off the visible range once all the others have been done, but I can't get my head round how to handle the synchronicity with the fact that when the richtextbox's contents change, the ranges will change too. Should I consider this a thing that takes 'a long time' to happen? Or can anyone else lend a hand with the obviously huge amount of sideways thinking I'm having to do!!
It's for a syntax highlighting control, right now I'm just trying to get it to be able to parse c-style block comments, line comments and quotes (red.
Any ideas on performance in this area
Have posted to C++ groups as although I am writing the app in c# I am non too averse to turn my hand to c++
Thank
Sorry for that. But please please answer if you know anything about it..
Thanks
I've got a procedure that is responsible for performing the following operations on a richtextbox
1) determining what parts of the text to forma
2) formatting specific ranges of text a specific color
I need to do this whenever the contents of the richtextbox change. The algorithm is quite fast as I have built in some speed saving optimizations, but i need to do some more, I was wondering if anybody could give me any suggestions? So far, I've coded it to
* - retrieve information about all ranges 'as of now' but only setting the format of ones that are new / only unsetting the format of ones that were there but aren't no
* - only set the format of ranges that are visible. For this, I use the message EM_GETFIRSTVISIBLELINE to get the first visible line, and the line count by dividing the height by the height of a line (got by GetTextMetrics). But then I need to do a rescan of ranges to format on vscroll aswell as on textchange, which is a bit bad as it's slow when you scroll
I was thinking of having some sort of 'lazy updater' type thing that either runs for, say, 100 milliseconds each second, or in a different thread, to update the RTB for the ranges that are off the visible range once all the others have been done, but I can't get my head round how to handle the synchronicity with the fact that when the richtextbox's contents change, the ranges will change too. Should I consider this a thing that takes 'a long time' to happen? Or can anyone else lend a hand with the obviously huge amount of sideways thinking I'm having to do!!
It's for a syntax highlighting control, right now I'm just trying to get it to be able to parse c-style block comments, line comments and quotes (red.
Any ideas on performance in this area
Have posted to C++ groups as although I am writing the app in c# I am non too averse to turn my hand to c++
Thank