LanguageBase Members in WPF Syntax Editor

31 May 20233 minutes to read

LanguageBase class in Syncfusion.Windows.Edit namespace plays a vital role in the implementation of language support in EditControl. In order to include a support for a new or custom language, a class inherited from LanguageBase or its sub classes need to be implemented. LanguageBase contains a number of properties and methods to enable the custom language developers configure their languages easily. This topic discusses about the properties and methods available in the LanguageBase class.

Properties

The following table lists the properties available in LanguageBase class and its usage.

Property name

Type

Description

ApplyColoring

Boolean

Gets or sets a value indicating if the language supports syntax highlighting.

BlockEnd

String

Gets or sets a value indicating the end text that denotes end of a block in code.

BlockStart

String

Gets or sets a value indicating the start text that denotes Start of a block in code.

CaseSensitive

Boolean

Gets or sets a value indicating whether the Language has Case Sensitive or not.

CommitsIntellisenseItemOnSpaceBar

Boolean

Gets or sets a value indicating whether the selected Intellisense items to be appended when space bar is pressed.

EllipsisText

String

Gets or sets a value indicating the text to be displayed when a block is collapsed. By default it is set to "...".

FileExtension

String

Gets or sets File Extension supported by the language.

Formats

IEnumerable

Gets or sets a collection of type of IFormat indicating the language configurations. It has been modified to IEnumerable type to allow the users to binding a custom collection as language formats.

IntellisenseCommitCharacters

String

Gets or sets a value indicating when the selected Intellisense items to be appended. The string given will be converted to individual characters internally and verified to append the selected item to text.

IntellisenseDrillDownChar

Char

Gets or sets a value indicating a char on which the

sub-items of the intellisense items to displayed.

IsSplitTextToWords

Boolean

Gets or sets a value indicating if the text in lines has to be spitted into tokens.

Lexem

IEnumerable

Gets or sets a collection of type of ILexem indicating the language configurations. It has been modified to IEnumerable type to allow the users to bind a custom collection as language lexems.

Name

String

Gets or sets Name of the Language.

ParentControl

EditControl

Gets a value indicating the Parent EditControl’s reference.

SplitLinesRegex

String

Gets or sets a value indicating the Regex to be applied for splitting the text in lines.

SplitWordsRegex

String

Gets or sets a value indicating the Regex to be applied for splitting the lines into individual tokens.

SupportsIntellisense

Boolean

Gets or sets a value indicating whether the language supports IntelliSense or not.

SupportsOutlining

Boolean

Gets or sets a value indicating whether the language supports Outlining.

TextForeground

Brush

Gets or sets Foreground brush to be applied when no Lexems are applicable for the text.

Methods

The following table lists the methods available in LanguageBase class and its purpose.

Method

Return Type

Description

ApplyColor(string text, int line);

IFormat

Helper method to apply coloring to the text based on the Lexems in the Language configurations. It is a protected method and can be overridden in the sub classes. The method is used to manipulate the Format to be applied to a particular token in a line.

ApplyExpandCollapse(ApplyExpandCollapseArgs args)

Void

Helper method to perform Expand Collapse for line items. When custom expand collapse logics is implemented, the methods can be overridden.This method runs in a background thread to overcome performance hits.Usage of any properties and methods outside the scope of the thread may result in an exception.

ApplyExpandItems()

Void

Helper method to Apply Expansions for the content in the EditControl. This method can be called if the Expand Collapse has to be refreshed for entire text in EditControl.

HideIntellisensePopup()

Void

Helper method to Hide Intellisense Pop-up.

InitializeExpandCollapse()

Void

This method is called before the ApplyExpandCollapse and can be used to perform any Initialization operations.

PositionIntellisensePopup(int line, int index)

Void

Helper method to adjust the Position of the Intellisense box. Line value in parameter

represents the line number (starts of 0)

and index in the parameter

represents the cursor index

RefreshExpandItems(int line)

Void

Helper method to Refresh lines expansions from a specified line number. Line value in parameter refers to the index (starts from 0)

ShowIntellisenseBox(EditIntellisenseArgs args)

Void

Helper method to Show the Intellisense pop-up.

SplitTextToLines()

Void

A helper method to Split the text in the EditControl into individual lines.