Page 1 of 1

Text style conversion

Posted: Fri Sep 21, 2007 12:38 pm
by martindholmes
I'm having trouble with something very simple, but I just can't figure out how to do it. I need to do a text style conversion over a range of text which may include several items, and may begin and end in the middle of items. So I need to:
  • Split the first item where the selection starts, and create a new item from the second part of it;

    Create a new style for that item based on the existing style, with modifications, and apply it;

    For each subsequent item which is completely inside the selection, create a new style based on its current style with my modifications, and apply it;

    for the last item, split it at the point where the selection ends, create a new item from the first part of it, and apply a modified style to that.
I know this must be straightforward, because I see it working in the Action Test demo -- so if I select a sequence of text that starts in the middle of a bold item, goes through a normal text item, and ends in the middle of an italicized item, then press Underline, each part of the selection is modified correctly. But I can't find the code which does this -- Action Test is huge, and I've never been able to get it to load in Delphi 2005 so I could debug it. (I get lots of errors about components not being found; I've never been able to get RVActions installed correctly.)

Is there an example somewhere of how to do this?

Cheers,
Martin

Posted: Fri Sep 21, 2007 1:46 pm
by Sergey Tkachenko
ApplyStyleConversion method + OnStyleConversion event.
See Demos\Delphi\Editors\Editor 2\

Text style conversion

Posted: Fri Nov 16, 2007 4:09 pm
by MiguelMoron
Hi

But... it is posible change styles (many items selected) without OnStyleConversion event....
so like as:

rve.ApplyTextStyle(NewStyleNo)

.... but for many items in seleccion....

(PD.) Sorry for bad english

Posted: Fri Nov 16, 2007 9:00 pm
by martindholmes
That's true, but in my situation I'm not applying a single style to all the items: I'm creating new styles for each item based on their existing style, with some modifications. In other words, they don't all end up looking identical; they all end up changed, but different.

I did figure out how to do this based on Sergei's advice, though.

Cheers,
Martin