Custom collapsible region

I'm using the EditControl to allow editing of a proprietary scripting language.
In this language, a semi-colon (";") denotes the beginning of a comment.

I'd also like to use ";region" and ";endregion" to denote custom sections that could be collapsed without interfering with the idea that a semi-colon under other circumstances is a comment. So, something like this where the region/endregion section could be collapsible. 

Is that possible?

;region Variable Section

; this is just a regular comment
x = "Will"
y = "This"
z = "Work?"


;endregion



1 Reply

MK Mallika Kannan Syncfusion Team March 2, 2018 12:54 PM UTC

Hi Mark Atkinson 
 
Thank you for contacting Syncfusion support. 
 
We have checked your query “ ; as Comment and ;region and ;endregion make collapsed region” and prepared sample which tries to meet your requirement. The requirement be achieved by setting the collapsed region on config file using lexem. In this sample, we have set the collapsed region by setting  ;region as BeginBlock,  ;endregion as EndBlock and enable the IsCollapsable property. The following code demonstrates the same. 
 
Code Example: [Xaml] 
 
<ConfigLanguage name="CustomLanguage" CaseInsensitive="true"> 
<formats> 
<format name="Text" Font="Courier New, 10pt" FontColor="Black" /> 
<format name="PreprocessorKeyword" Font="Courier New, 10pt" FontColor="Red" /> 
<format name="Comment" Font="Courier New, 10pt" FontColor="Green" /> 
<format name="CollapsedText" Font="Courier New, 10pt" FontColor="Red" BackColor="White" 
BorderColor="Gray" BorderStyle="Solid" /> 
</formats> 
<extensions> 
<extension>cl</extension> 
</extensions> 
<lexems> 
<!-- ; denotes the comment--> 
<lexem BeginBlock=";" EndBlock="\n" IsEndRegex="true" Type="Comment" IsComplex="true" OnlyLocalSublexems="true" /> 
 
<!-- For collapsed region --> 
<lexem BeginBlock=";region"  EndBlock=";endregion" Type="PreprocessorKeyword" IsEndRegex="false" 
IsComplex="true" IsCollapsable="true" AutoNameExpression='(;region)\s*"(?&lt;text>.*)".*(?&lt;!\n)\n' 
AutoNameTemplate="${text}" IsCollapseAutoNamed="true" CollapseName="Variable Section"> 
<SubLexems> 
<lexem BeginBlock="\n" IsBeginRegex="true"/> 
</SubLexems> 
</lexem> 
</lexems> 
<splits> 
<split>;region</split> 
<split>;endregion</split> 
</splits> 
</ConfigLanguage> 
 
Code Example: [C#] 
 
//Define config file path 
private string configPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\..\\..\\Config.xml"; 
 
// External configuration file. 
this.editControl1.Configurator.Open(configPath); 
// Apply the configuration defined in the configuration file. 
this.editControl1.ApplyConfiguration("CustomLanguage");                        
 
Screenshot 
 
 
 
 
Please try this above solution and let us know if it is helpful. 
 
Regards, 
Mallika 


Loader.
Up arrow icon