Text style conversion

General TRichView support forum. Please post your questions here
Post Reply
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Text style conversion

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

ApplyStyleConversion method + OnStyleConversion event.
See Demos\Delphi\Editors\Editor 2\
MiguelMoron
Posts: 2
Joined: Fri Nov 16, 2007 3:57 pm

Text style conversion

Post 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
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Post 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
Post Reply