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

Highlighting 2 Different Colors on 1 Lexem

Thread ID:

Created:

Updated:

Platform:

Replies:

124309 May 31,2016 10:55 AM UTC Jul 13,2016 09:02 AM UTC WinForms 4
loading
Tags: EditControl
Frank Hilton
Asked On May 31, 2016 10:55 AM UTC

Hi,

I am trying to highlight two different colors on one Lexem.
This is for music chords.... I want the [" and "]" to be one color and the actual chord all red.

My formats are okay... won't show them here

Example output....

[Bbmaj7]

See code...

<lexem BeginBlock="[" EndBlock="]" Type="Operator" IsComplex="true">
<SubLexems>
<lexem BeginBlock="[1-9a-gA-G]" EndBlock="[1-9a-gA-G]" IsEndRegex="true" Type="Custom" FormatName="Chord" />
</SubLexems>
</lexem>

Do I have to parse them separately or can I do them using Sublexems like above?

Thanks in Addvance

Vinothini [Syncfusion]
Replied On June 2, 2016 07:29 AM UTC

Hi Frank,

 

Thank you for contacting Syncfusion support.

 

This requirement for highlighting two different colors can be achieved by using sublexems as per your code. In addition we need to configure the lexem in the Sublexem region using Split, which contain list of expressions that must be treated as a single word. Since the sublexem includes the regular expression content we need to include the following code snippet in the configuration file.

 

Code Snippet [XML] : 

 

<splits>

   <split IsRegex="true">[A-Ga-g0-9]</split>

   <split IsRegex="true">[0-9A-Ga-g]</split>

</splits>

 

 

We have prepared a sample for your reference which can be downloaded from the following location.

 

Sample Location : http://www.syncfusion.com/downloads/support/directtrac/general/EDITCO~1-628836919.ZIP

 

Please let us know whether this solution satisfies your requirement.

 

Regards,

Vinothini


Ranjani Prabhakaran [Syncfusion]
Replied On July 12, 2016 05:33 AM UTC

  
Hi, 
 
That code works…. THANK YOU! 
 
Next Q: (I looked all  through the docs, couldn’t find the answer). 
 
How do I redraw the colored text once I edit the contents of the edit box? 
I tried refresh() and it doesn’t seem to work. 
 
Ex…. 
“[Gmaj]” then becomes “[Gbmaj7]” when I edit the text during runtime. 
The “b” & “7” stay black while the other text stays colored 
 
Thanks 
 
 
Frank Hilton  


Frank Hilton
Replied On July 12, 2016 11:56 AM UTC

I figured it out. I had to update the Config.XML

However, the application I am building...
I need to know how to update (re-paint) the text in the editor.
I am going to be building a "Transpose" function that changes all the chords in the editor.

So, can you explain to me what actually happens when I have to replace text.
Does the editor automatically redraw?
How does it "refresh"?

Thanks

Venkateshwaran Ramdoss [Syncfusion]
Replied On July 13, 2016 09:02 AM UTC

Hi Frank, 

Thank you for your update. 

Query 1: Need to know how to rendering functionality works in EditControl  
 
In EditControl, Text Input will be rendered always and Syntax coloring will be applied based on the definitions provided in EditControl.  

Query 2: Implementing function to update the Chords 
 
We are unable to understand this. Could you please let us know what is updated in EditControl, with an example? 

Query 3: Will Text will be rendered automatically when it is replaced in EditControl? 
 
Yes, EditControl will be re-rendered based on its Text Input update.  

Otherwise, would it be possible for you to share us the sample for this? That will be helpful for us to analyze and provide prompt solution at the earliest.  

Regards, 
Venkateshwaran V.R. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;