SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Using TextEditor control with custom syntax highlighting

Last post 12-29-2008 8:33 PM by dalewheat. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-29-2008 7:40 PM

    • dalewheat
    • Not Ranked
    • Joined on 12-28-2008
    • Dallas TX USA
    • Posts 5

    Using TextEditor control with custom syntax highlighting

     I'm new to C# and .NET development, so please be gentle.  I have programmed in C for most of my life.  I am trying to learn the New Ways.  Here is my question:

     I am evolving a set of tools for working on embedded projects using microcontrollers.  I would like to use the sharpdevelop TextEditor control in a C# Windows Forms application.  I am able to create simple projects using SharpDevelop.  I have been able to drop the TextEditor control onto a form and set its various properties.  I have also created the skeleton of a syntax highlighting definition file.  How do I tell the TextEditor to use this file for syntax highlighting?  I just want to turn comments a different color to begin with and get bolder as I learn more about how this control works.

    I appreciate any feedback.  Please bear in mind that I am basically unfamiliar with all the features of the SharpDevelop environment.

     Dale Wheat

    http://dalewheat.com

     

  • 12-29-2008 7:50 PM In reply to

    Re: Using TextEditor control with custom syntax highlighting

    Take a look at the wiki.
  • 12-29-2008 8:03 PM In reply to

    • dalewheat
    • Not Ranked
    • Joined on 12-28-2008
    • Dallas TX USA
    • Posts 5

    Re: Using TextEditor control with custom syntax highlighting

     Thanks for your prompt reply, Matt.

     As I am wanting to eventually contain all this functionality in a program separate and apart from the SharpDevelop environment, is there any way to embed (hard code) this syntax definition file in my application instead of in an external file, as documented in the wiki article?

    Thanks,

    Dale Wheat

     

  • 12-29-2008 8:17 PM In reply to

    Re: Using TextEditor control with custom syntax highlighting

    You can write your own ISyntaxModeFileProvider implementation that loads the file from a different location (e.g. embedded resource)

        public interface ISyntaxModeFileProvider
        {
            ICollection<SyntaxMode> SyntaxModes { get; }
            
            XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode);
            void UpdateSyntaxModeList();
        }

    The SyntaxModes collection must return a list of modes used by your application - simply use the appropriate SyntaxMode constructor. For the Syntaxmode class, "FileName" doesn't have to be a real file, it can also be a resource name.

    Then implement GetSyntaxModeFile to open an XmlTextReader for that syntax mode.

    UpdateSyntaxModeList can stay empty, it's only used if your list of syntax modes changes at runtime.

  • 12-29-2008 8:33 PM In reply to

    • dalewheat
    • Not Ranked
    • Joined on 12-28-2008
    • Dallas TX USA
    • Posts 5

    Re: Using TextEditor control with custom syntax highlighting

     Matt,

     Thank you for the detailed reply.  I will try to implement this technique and see if I can learn about what all is involved.  This will be interesting as I barely know what a class is!  :)

    Thanks,

    Dale Wheat

     

Page 1 of 1 (5 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.