Finding a way to extend the DefaultWordBreakFinder's WordStandaloneCharacters

SyntaxEditor for WPF Forum

Posted 3 years ago by Erwin Liong
Version: 16.1.0633
Platform: .NET 4.5
Environment: Windows 10 (64-bit)
Avatar

Hi Actipro,

 

I am using the ITextSnapshot's GetWordTextRange to get the text range of a certain word. In my context, certain character combinations should be accepted as a single word. For example, "<>" or "!=" should be accepted as single word representing NOT; or ".." representing a range; "<=", ">="; and many others such as "[:=]". 

 

I have seen the DefaultWordBreakFinder has a set of predefined standalone characters. With the current predefiend set, I am not able to get the correct WordTextRange. I am planning to extend the WordStandaloneCharacters in DefaultWordBreakFinder to additionally include my set of delimiters.

Is there a way these can be exteded to hold a string? Or, is there a better way of achieving this?

 

Thank you.

Comments (2)

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

Hi Erwin,

The DefaultWordBreakFinder properties like WordStandaloneCharacters are CharClass properties.  You can update or set those however you need, and they will alter the logic DefaultWordBreakFinder has.

If you are looking to do something more complex though (which based on your post, it seems like you do), you could make a custom class that implements IWordBreakFinder.  That way you could have the various methods better handle scenarios like navigating around "<>" as a word, etc.


Actipro Software Support

Posted 3 years ago by Erwin Liong
Avatar

Hi Actipro, 

 

Understood. Thank you for the help. 

 

Cheers. 

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

Add Comment

Please log in to a validated account to post comments.