Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

j@hnny

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonny - 01 Jun 2004 10:21 GMT
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++

Thanks
Bad_Kid - 01 Jun 2004 23:33 GMT
I see we were thinking on the same thing ;-)
but, as you said, when scrolling -> it is a total disaster!
the quickest way is to color all text at once(when opening) or when
riting  - line by line... (i think...)
maybe this will help:

http://www.c-sharpcorner.com/Code/2003/June/ColorSyntaxEditor.asp
B0nj - 02 Jun 2004 21:12 GMT
ah, cheers - looks good i'll check it out.

> I see we were thinking on the same thing ;-)
> but, as you said, when scrolling -> it is a total disaster!
[quoted text clipped - 3 lines]
>
> http://www.c-sharpcorner.com/Code/2003/June/ColorSyntaxEditor.asp

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.