Recent

Author Topic: TRichMemo and quick updating of colors. Possible?  (Read 2672 times)

MortenB

  • New Member
  • *
  • Posts: 33
TRichMemo and quick updating of colors. Possible?
« on: October 12, 2015, 09:00:32 pm »
I recently started to experiment a bit with colors in the text in a TRichEditBox.
I first add the text, and then I need to do some colors.
My method for doing this is : rmSource.SetRangeColor(wPos, wLen,clGreen)
where "rmSource" is the name of my RichEditBox.
At first glance, this works flawlessly, but even on a short text (like the top two lines here) where I want to do some 20-30 different colorings, this begins to take a noticeable amount of time. Sometimes in my RichEditBox, there will be up to 1000 words, and to do the coloring I want, it takes about 5 seconds.
Anybody aware of a method to increase the speed? or another EditBox which is a lot quicker and gives the ability to change font style and color quickly?
As a bottom line. My wPos and wLen -variables are straight out of an Index, so this is as fast as it can be.
On a text with 1000 words, I do approx 100 000 calculations and comparisons in less than a second. I find it so strange that it takes 5 seconds just to add a little bit of color  >:D


skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2280
    • havefunsoft.com
Re: TRichMemo and quick updating of colors. Possible?
« Reply #1 on: October 12, 2015, 09:38:14 pm »
I presume you're talking about Win32?

The slowness comes from the code that tries to identify what ranges of styles you've in the selected range. Win32 doesn't provide any quick API in order to do that.

...hmm, maybe we could speed it up for you a bit.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2280
    • havefunsoft.com
Re: TRichMemo and quick updating of colors. Possible?
« Reply #2 on: October 12, 2015, 10:21:03 pm »
r4377 is ready for you, sir.

It should be slightly faster than 5 seconds.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

tk

  • Sr. Member
  • ****
  • Posts: 363
Re: TRichMemo and quick updating of colors. Possible?
« Reply #3 on: October 12, 2015, 10:30:34 pm »
You could try http://tkweb.eu/en/delphicomp/kmemo.html
It has very good support for mass formatting changes (update locking).
Plus it has fast methods to add text blocks and colorize them etc.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2280
    • havefunsoft.com
Re: TRichMemo and quick updating of colors. Possible?
« Reply #4 on: October 12, 2015, 10:34:41 pm »
You could try http://tkweb.eu/en/delphicomp/kmemo.html
It has very good support for mass formatting changes (update locking).
Plus it has fast methods to add text blocks and colorize them etc.
And it's free license. beautiful!
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

MortenB

  • New Member
  • *
  • Posts: 33
Re: TRichMemo and quick updating of colors. Possible?
« Reply #5 on: October 13, 2015, 08:30:48 am »
Thank you to all for your efforts trying to find me an answer and a solution :)
I think I will try to go for the K-Memo-component if I manage to install it on Lazarus :p
My software work wonders at the moment, although slow on the coloring part.

In my next free time, I will explore K-Memo.
But if the r4377 of TRichMemo is faster, maybe I should give it a shot first.
I suppose that will make the fix as easy as a recompile, and I don't really need anything fancy.
All same font and size (but changeable for the entire box) with coloring, background and Bold/Italic/Underline will do for me. Superscript/Subscript would be great, but no big need.