richedit / rtf: how to format text by hand? (fast coloring)
Posted on 2003-02-28
hello there, i'm really desperate about this one: i want to write a logfile viewer which should provide highlighting of specific words. so far so good, i know how to do it (CHARFORMAT2 etc.). but the logs i deal with become _huge_ (several MBs), so that loading them into the richedit control and then parsing them using the control's functions (even selstart, selend, selcolor) is by far too slow to use them.
so my idea would be to do the coloring myself, formatting the rtf sourcecode. there are very fast (assembler optimized) string controls out there, i grabbed one (faststrings) and it fulfils my needs.
the problem is the richedit control itself, it's making me feel dizzy... i need to copy the RAW rtf control codes to a buffer, then modify it and write it back (as RAW rtf data), the final goal is a richedit text with nicely colored words.
i learnt the rtf format, it's quite easy. at the beginning of the file, you can insert a colortable with all colors you need (or extend an existing one), in the file you can write in a specific color with \cfX where X is the index in the colortable, get back to normal vision using \cf0.
so this is not the problem.
but however i try to do it, i can't get the pure raw rtf text from a richedit control, than modify it and send it back...
help is really appreciated! thank you so much in advance!