How to trigger the TextFormatter from QuickStart.GettingStarted13-TextFormatter

SyntaxEditor .NET Languages Add-on for WPF Forum

Posted 5 years ago by Christel
Version: 14.1.0601
Avatar

Hi,

I want to trigger the TextFormatter programatically.

Which method of the syntaxeditor I have to call to trigger the TextFormatter.Format(TextSnapshotRange snapshotRange)?

When triggering by button_cklick, where can I see the code for the EditorCommands.FormatDocument?

 

Thanks

 

Christel

Comments (2)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christel,

Our Format Document action has some built-in code that helps retain selection.  But the core of the method effectively does:

ITextFormatter textFormatter = document.Language.GetTextFormatter();
textFormatter.Format(view.CurrentSnapshot.SnapshotRange);

You could just trigger our built in code with something like:

editor.ActiveView.ExecuteEditAction(new EditActions.FormatDocumentAction());


Actipro Software Support

Posted 5 years ago by Christel
Avatar

Thanks a lot for the really quick answer!!

It works perfect.

Great support as always!

 

Cheers

Christel

The latest build of this product (v2019.1 build 0683) was released 19 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.