Skip navigation
Currently Being Moderated

Technique to undo a character format application?

Sep 12, 2013 6:20 AM

Hi,

 

Seems that answers to complicated questions are a bit sparse in these parts, but I'll try again anyway

 

I'm wondering if there is any technique to reliably undo a character format application change; that is, an application of properties to a range of text with SetTextProps(). It is fairly simple to remember a list of original properties (PropVals) and the original text range (TextRange), then reapply those original properties to the whole range. However, within a text range, each character can have its own unique set of properties. So, remembering one set of original properties is not enough... seems I have to remember the properties of every single character in the range, the reapply character-by-character, in order to ensure that the new property application is completely undone.

 

When you apply a character format in the GUI, FM reliably allows an undo, restoring each affected character to its original state. Surely it isn't remembering a PropVals array for every single character (?)  I'm just wondering if there is another trick here. It's entirely possible if FM is internally using another trick, it isn't one that I can feasibly replicate.

 

Thanks,

Russ

 
Replies
  • Currently Being Moderated
    Sep 12, 2013 9:56 AM   in reply to Russ Ward

    Hi Russ,

     

    If you use a GetText method and use the Constants.FTI_CharPropsChange you should get an array of text items where each item has one particular set of properties. You should be able to save those for later restore. There should be no need to save the properties of each single character.

     

    Ciao

     

    Jang

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 13, 2013 8:38 AM   in reply to Russ Ward

    Hi Russ,

     

    You don't need to actually do the GetProps until the moment when something needs to be undone. Keep the array of TextItems until it is no longer needed. Thinking out loud as well, this leads me to the original question: what is it exactly that you want to restore?

     

    You could keep a safety copy of a Pgf every time something within that Pgf is changed. Then restoring becomes retrieving the entire Pgf and overwriting the changed Pgf with it. Similar for other objects, but as you mention character formats I assume saving a verison of a Pgf on every change inside it should do the trick.

     

    Ciao

     

    Jang

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points