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

Problem with syntax highlight occurring in plain text file

Thread ID:

Created:

Updated:

Platform:

Replies:

118119 Feb 3,2015 01:03 AM UTC Feb 19,2015 05:07 AM UTC Windows Forms 13
loading
Tags: EditControl
Alan Burkhart
Asked On February 3, 2015 01:03 AM UTC

I'm new to Syncfusion so this is likely a case of me doing something wrong. I'm using a class derived from the EditControl. No radical changes just a couple of extra properties.

My problem is that in a .txt file any text between two apostrophes (single quote) is highlighted in red.
Example: In the string "I've gone as far as I'm able to go" the text "ve gone as far as I" is in red. And it's often dropped to the next line.

Any ideas?

Senthil Kumaran Rajan [Syncfusion]
Replied On February 3, 2015 12:19 PM UTC

Hi Alan,

Thank you for using Syncfusion products,

Yes, Kindly request you to confirm, if you have enabled syntax formatting in EditControl by using Config.xml. If so, please check if you have set font color for string as “Red” as in below code snippet.

Code Snippet[XML]

//To Change the color of the String

<format name="String" Font="Courier New, 10pt, style=Bold" FontColor="Red" />

And also verify if you have defined, characters given between quotes to be considered as “string” like in below code snippet.

Code Snippet[XML];

//The text inside the Double quotes is mentioned as string Type

<lexem BeginBlock="&quot;" EndBlock="(&quot;)|(@&quot;)" Type="String" IsEndRegex="true"

    IsComplex="true" OnlyLocalSublexems="true">

   <SubLexems>

     <lexem BeginBlock="\" EndBlock="&quot;" Type="String" />

   </SubLexems>

</lexem>

//The text inside the Single quotes is mentioned as string Type

<lexem BeginBlock="'" ContinueBlock=".*" EndBlock="'" IsContinueRegex="true" Type="String" />

If so, we suggest you to either comment above code snippet or set string FontColor as per you requirement.

We have also prepared sample for your reference and this will be available in the below link.

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/118119/EditControl-1095598480.zip

And additionally, we could able to find as string given inside quotes is displayed, in user defined line index. Could you please check this above solution and let us know if it helps? Otherwise can you please share us the sample that can reproduce reported behavior? That will be helpful for us to analyze and provide prompt solution as earlier as possible.

Please let us know if you need further assistance,

Regards,

Senthil kumaran



Revathi K [Syncfusion]
Replied On February 4, 2015 06:15 AM UTC

From: Alan Burkhart [mailto:burkhartonline@yahoo.com]
Sent: Wednesday, February 04, 2015 12:55 AM
To: Syncfusion Support
Subject: Re: Syncfusion support community forum 118119, Problem with syntax highlight occurring in plain text file, has been updated.

I had not added Config.xml to the project. When I did and changed the xml as you mentioned part of the red text changed to black (these are .txt files). Some html files however still display red text where black is expected (between some <span></span> tags for example). The color changes do not occur in my old editor, which uses the ScintillaNet control (.net wrapper for Scintilla).

I created a test project and dragged an EditControl into the form and loaded one of the text files in question. The behavior (red text) was the same as in my derived class.

The plain text files, when word wrap is enabled, break English contractions like "I'm" at the apostrophe. Could this be a setting in word wrap that I need to change?

 Thank you for your assistance and your patience. I'm rather excited to finally be able to try out your products.

Alan Burkhart

Nothing sways the stupid more than arguments they can't understand. - Cardinal de Retz



Revathi K [Syncfusion]
Replied On February 5, 2015 04:35 AM UTC

From: Alan Burkhart [mailto:burkhartonline@yahoo.com]
Sent: Wednesday, February 04, 2015 7:37 PM
To: Syncfusion Support
Subject: Re: Syncfusion support community forum 118119, Problem with syntax highlight occurring in plain text file, has been updated.

Update:

I resolved the original problem by cutting out most of the "Text" portion of Config.xml so that plain text files remain unformatted except for the font. A possible problem remains in HTML files. As you can see in the attached image, a word containing an apostrophe changes the color for the rest of the line including the closing tag. Is it expected that I use the decimal symbol instead of the actual character? Not a huge problem of course but I was curious since many editors support use of the apostrophe in displayed text.

 Thanks -- Alan Burkhart

Nothing sways the stupid more than arguments they can't understand. - Cardinal de Retz
 
ApostropheProblem.zip

 



Revathi K [Syncfusion]
Replied On February 5, 2015 04:35 AM UTC

From: Alan Burkhart [mailto:burkhartonline@yahoo.com]
Sent: Wednesday, February 04, 2015 7:37 PM
To: Syncfusion Support
Subject: Re: Syncfusion support community forum 118119, Problem with syntax highlight occurring in plain text file, has been updated.

Update:

I resolved the original problem by cutting out most of the "Text" portion of Config.xml so that plain text files remain unformatted except for the font. A possible problem remains in HTML files. As you can see in the attached image, a word containing an apostrophe changes the color for the rest of the line including the closing tag. Is it expected that I use the decimal symbol instead of the actual character? Not a huge problem of course but I was curious since many editors support use of the apostrophe in displayed text.

 Thanks -- Alan Burkhart

Nothing sways the stupid more than arguments they can't understand. - Cardinal de Retz
 
ApostropheProblem.zip

 



Revathi K [Syncfusion]
Replied On February 5, 2015 04:35 AM UTC

From: Alan Burkhart [mailto:burkhartonline@yahoo.com]
Sent: Wednesday, February 04, 2015 7:37 PM
To: Syncfusion Support
Subject: Re: Syncfusion support community forum 118119, Problem with syntax highlight occurring in plain text file, has been updated.

Update:

I resolved the original problem by cutting out most of the "Text" portion of Config.xml so that plain text files remain unformatted except for the font. A possible problem remains in HTML files. As you can see in the attached image, a word containing an apostrophe changes the color for the rest of the line including the closing tag. Is it expected that I use the decimal symbol instead of the actual character? Not a huge problem of course but I was curious since many editors support use of the apostrophe in displayed text.

 Thanks -- Alan Burkhart

Nothing sways the stupid more than arguments they can't understand. - Cardinal de Retz
 
ApostropheProblem.zip

 



Ashwini Jaya Preetha Durai Samy [Syncfusion]
Replied On February 5, 2015 12:13 PM UTC

Hi Alan,

 

Thank you for the update,

 

We would like to let you know that, in Editcontrol Config.xml file contains set of language configurations. It is possible to customize font color for the strings in all language file by using the Config.XML file. Please refer the below UG link.

 

UG Link: http://help.syncfusion.com/ug/windows%20forms/default.htm#!documents/creatingacustomlangu.htm

The stated requirement in EditControl can be achieved by setting the font color for “String” in Html ConfigLanguage as in the below code snippet.

 

Code snippet[XML]:

 

 

<ConfigLanguage name="HTML (Light)" CaseInsensitive="true" Known="HTML" StartComment="&lt;!--" EndComment="--&gt;">

<formats>

   //To Set the String forecolor

   <format name="Text" Font="Courier New, 10pt" FontColor="Black" />

   <format name="Whitespace" Font="Courier New, 10pt" FontColor="Black" />

   <format name="TagName" Font="Courier New, 10pt" FontColor="Black" />

   <format name="AttributeName" Font="Courier New, 10pt" FontColor="Black" />

   <format name="String" Font="Courier New, 10pt" FontColor="Black" />

</formats>

</ConfigLanguage>

 

 

 

We have also modified the sample to meet the reported requirement and it can be downloaded from the following link.

 

Sample link: http://www.syncfusion.com/downloads/support/directtrac/118119/EditControl704666009.zip

 

Please look into the sample and kindly let us know if it meets your requirement. If not could you please share us the sample that can reproduce the reported behavior? That will be helpful for us to analyze and provide you the prompt solution as earlier as possible.

 

Please let us know if you need further assistance,

 

Regards,

Ashwini.


Saranya CJ [Syncfusion]
Replied On February 13, 2015 04:41 AM UTC

From: Alan Burkhart [mailto:burkhartonline@yahoo.com]
Sent: Thursday, February 12, 2015 9:32 PM
To: Syncfusion Support
Subject: Re: Syncfusion support community forum 118119, Problem with syntax highlight occurring in plain text file, has been updated.

The problem with the presence of an apostrophe recoloring the text occurs in the Config.xml file. I solved it by commenting out the below line of code in the HTML language section of the file:

<lexem BeginBlock="'" EndBlock="'" Type="String" IsComplex="true" OnlyLocalSublexems="true" />

This prevents the apostrophe from having any ill effect. An apostrophe must be replaced with "&apos;" in XML files, but this is not required in HTML. The few other issues I was encountering were mostly just a part of the learning process as I am new to your product. 

One other question: I'm using the TabbedMDIManager along with EditControls in a project. When a new, empty file is created, I cannot set the EditControl.Filename property to "untitled.txt". No exception is thrown but the command has no effect. How to resolve this?

Overall I must say I am well-pleased with the controls I've tried thus far, and also with the quick and courteous replies to my questions. It's greatly appreciated and I will recommend your product to others without hesitation.

 Alan Burkhart

Nothing sways the stupid more than arguments they can't understand. - Cardinal de Retz



Ashwini Jaya Preetha Durai Samy [Syncfusion]
Replied On February 17, 2015 07:18 AM UTC

Hi Alan,

 

Thank you for the valuable comment.

 

We would like to let you know that we are unable to get details of your query clearly. While using the FileName property of EditControl it will save the file with given name and format using the file save dialog box. We have prepared a sample for your requirement and it can be downloaded from the following location.

 

Sample location: http://www.syncfusion.com/downloads/support/directtrac/118119/EditControlSample-135653270.zip

 

Please look into the sample and kindly let us know if we have misunderstood your query. If so please provide us more details like reproducing steps, so that we can analyze and provide you the prompt solution as earlier as possible.

 

Please let us know if you need further assistance,

 

Regards,

Ashwini.


Alan Burkhart
Replied On February 17, 2015 09:23 AM UTC

The problem occurs when creating a new, empty file. I'm using EditControl together with the TabbedMDIManager. My MDI child window is a Windows form with an EditControl. All works well when loading an existing file. But when an empty file is created with a generated file name I cannot set the EditControl.FileName property to the generated name, and so the tab in the TabbedMDIManager is empty (no text). Here is my code for loading files, where the variable "fPath" holds the file name:

'set the file name and load file...
            If File.Exists(fPath) Then
                edCtrl.LoadFile(fPath)
            Else
'set FileName property in new empty file...
                unt += 1
                edCtrl.FileName = "untitled_" & unt.ToString & ".txt"
            End If

'set the text of the child window (and the corresponding tab) according to the length of the file name
            Dim frm As New Form
            AddHandler frm.Activated, AddressOf childWin_Activated
            If Path.GetFileName(edCtrl.FileName).Length > 25 Then
                Dim ext As String = Path.GetExtension(edCtrl.FileName)
                frm.Text = Path.GetFileName(edCtrl.FileName).Substring(0, 20) & "…" & ext

            Else
                frm.Text = Path.GetFileName(edCtrl.FileName)
            End If

            frm.Controls.Add(edCtrl)
            frm.MdiParent = Me
            frm.Show()

This If-Then-Else code does not throw an exception, but with a new "untitled" file the FileName property remains empty after I set it. I have worked around this by using the fPath variable instead of the FileName property when creating the child form's text. This is not necessary with an existing file since the FileName property is set when the file is loaded.


Vinothini [Syncfusion]
Replied On February 18, 2015 01:09 PM UTC

Hi Alan,

Thank you for your update.

Your requirement for displaying the EditControl filename in the child window of the TabbedMdiManager can be achieved by using DisplayedFileName property in EditControl. Please make use of the below code snippet .

Code Snippet [VB]:

frm.Text = Path.GetFileName(edCtrl.DisplayedFileName)

Also could you please look into the video from the following location and let us know whether this is your reported requirement.

Video Location : http://www.syncfusion.com/uploads/user/directTrac/118119/Edit390176742.zip
Please let us know if you need any further assistance.

Regards,
Vinothini.R



Vinothini [Syncfusion]
Replied On February 18, 2015 02:33 PM UTC

Hi Alan,

We have also prepared sample for your requirement. Please download it from the following location.

Sample Location: http://www.syncfusion.com/uploads/user/directTrac/118119/EditControl-908545549.zip 

Regards,

Vinothini.R



Alan Burkhart
Replied On February 19, 2015 04:03 AM UTC

The DisplayedFileName property was exactly what I needed. Many thanks!

Ashwini Jaya Preetha Durai Samy [Syncfusion]
Replied On February 19, 2015 05:07 AM UTC

Hi Alan,

 

We are glad that, we have helped you on this.

 

Please let us know if you need further assistance,

 

Regards,

 Ashwini

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

;