We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can syntax highlighting be applied for Powershell language in the EditControl?

The EditControl has a built-in syntax highlighting support for the following languages.

  1. C Sharp.
  2. VB.NET.
  3. HTML.
  4. XML.
  5. Pascal.
  6. Delphi.
  7. SQL.
  8. Java.
  9. VBScript.
  10.  Jscript.

 

Additionally, the custom language can be configured in the EditControl by using the configuration file. By configuring the custom language in the EditControl, you can define the syntax coloring based on the requirement. The following steps help you to configure the syntax coloring for the PowerShell language.

 

Custom Language Configuration:

  1. Initialize the configuration language.
  2. Extensions.
  3. Splits.
  4. Formats.
  5. Lexems.
  6. AutoReplaceTriggers.

 

Initialize the Configuration Language:

Set the configured language by using the ConfigLanguage tag attribute. When the language is case insensitive, you should set the CaseInsensitive attribute to true.

The following code example demonstrates the same.

XML

 

Extensions:

Extensions contain a list of extensions that are associated with that particular language.

 

Splits:

Splits contain a list of expressions that must be treated as one word. “=” and “+” are splitters, by default. So, each of them are returned by the tokenizer as a single char. For example, when you want to specify a configuration for “+=”, you should specify “+=” in the splits section.

You can combine multiple keywords as a single keyword. To configure the splits, specify the required word in the split section.

The following code example demonstrates the same.

 

XML

 

See also to configure the Splits in the EditControl

 

Formats:

This section helps you to initialize the Format strings. The Format assigns the syntax coloring for the keywords, text, comment tag, etc.

 The following code example demonstrates the same.

 

XML

 

Note: Every format contains the attributes such as name, font, fore color, font color, back color, style, weight, underline, and line color.

 

Lexems:

The Lexem contains rules for parsing the text. There are two attributes to specify the format of the lexem.

  1. Type: The Type is used for standard predefined types of the lexems.
  2. FormatName: The FormatName is used only when Type is Custom.

The following code example demonstrates the same.

 

XML

 

Note: Lexems are used to initialize the lexem option and to define the keyword, operands, number, string, etc.

 

AutoReplaceTriggers:

The AutoReplaceTrigger option helps you to autocorrect the mistakes in the EditControl.

The following code example demonstrates the same.

 

XML

 

After configuring the custom language, the configured file can be applied to the EditControl by using the Configurator.Open function in the EditControl. The text coloring of the specified language can be applied to the EditControl by using the ApplyConfiguration function in the EditControl.

The following code examples help you to configure the custom language in the EditControl.

 

C#

 

VB

 

Note: The custom specified language files can be opened by using the LoadFile function in the EditControl.

 

Intellisense support in EditControl:

You can provide the intellisence support to the EditControl by handling the ContextChoiceOpen event.

The following code example demonstrates the same.

C#

 

VB

 

 

Figure 1: EditControl configured with PowerShell language

Figure 2: Intellisence in EditControl

Sample Links:

C#: EditControl_PowerShellLanguage_C#

VB: EditControl_PowerShellLanguage_VB

Article ID: Published Date: Last Revised Date: Platform: Control:
5408 09/04/2015 09/04/2015 Windows Forms EditControl
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon