tags:

views:

117

answers:

4

Say I want to create a source code editor for ocaml programming language, where do I start? I am looking to create an editor for the Windows platform as a hobby project. My primary skill is in web development. I have developed windows apps long time ago. I have no clue how it is done with todays available tools. I have visual studio 2008 and C# is my language of choice.

+2  A: 

If you are most comfortable in Visual Studio, then you can use the Visual Studio Shell to create your own IDE based on that foundation.

Here is a podcast that gives a good overview: http://www.code-magazine.com/codecast/index.aspx?messageid=32b9401a-140d-4acb-95bb-6accd3a3dafc

Also, as a reference, the IronPython Studio was created using the Visual Studio 2008 Shell: http://ironpythonstudio.codeplex.com/

Browsing that source code should give you a good starting point.

Ben Hoffstein
Thanks a lot for answer Ben. I will definitely take a look at the overview of vs shell and also the ironpython studio.
Animesh
+2  A: 

You need to know:

  • OCAML Syntax, Features, Keywords, Functions etc...
  • C# as this is your native language I guess
  • You need to know what features you wanna implement
  • ...if it's using a GUI or just from a terminal like nano/vim
  • how syntax highlighting works
  • how to open and save files
  • how autocompletion works
  • etc..

You might want to take look at some open source editors like dev-c++ or gedit

Also, as you in person are more web-devvy, you might want to start creating one which runs in a web browser. This is often easier and helps you understand the basics of creating a code editor. Later you can always write one for desktops.

Time Machine
Thanks Koning. I appreciate your answer. This is what I am exactly looking for. I needed somewhere to start. This is it.Thanks.
Animesh
No problem. What most people don't know is that Koning is Dutch for King. Everyone here calls me a king without even knowing. BTW, thx I almost have 2000rep now ^^^
Time Machine
haha.. well now we know..cheers..
Animesh
enjoy your 2K. :)
Animesh
+2  A: 

You could use Scintilla. It has syntax highlighting and some other features. Also, it has a .NET Version available here.

Another good tool is Alsing Syntax Box:

Powerful Syntax Highlight Windows Forms Control for the Microsoft.NET Platform. Written in 100% managed C#. Supports syntax highlighting and code folding for just about any programming language.

With Alsing Syntax Box, you can define a syntax file (just like this one for C#) and later have a intellisense like feature.

You can start with one of them for your editor.

Fernando
SciTE is my second favorite editor. I will look at the both the tools you have mentioned. Thanks!
Animesh
+1  A: 

a lighter-weight alternative is to use the RichEdit control

example:
http://www.codeproject.com/Messages/3401956/NET-Richedit-Control.aspx

// http://www.codeproject.com/Messages/3401956/NET-Richedit-Control.aspx

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace RichEditor
{
    public class RichTextBoxEx : RichTextBox    
    {
        IntPtr mHandle = IntPtr.Zero;

        protected override CreateParams CreateParams        
        {
            get
            {
                // Prevent module being loaded multiple times.
                if (this.mHandle == IntPtr.Zero)                
                {
                    // load the library to obtain an instance of the RichEdit50 class.
                    this.mHandle = LoadLibrary("msftedit.dll");                
                }
                // If module loaded, reset ClassName.
                if (this.mHandle != IntPtr.Zero)                 
                {
                    CreateParams cParams = base.CreateParams;
                    // Check Unicode or ANSI system and set appropriate ClassName.
                    if (Marshal.SystemDefaultCharSize == 1)                     
                    {
                        cParams.ClassName = "RichEdit50A";                    
                    }
                    else
                    {
                        cParams.ClassName = "RichEdit50W";                    
                    }
                    return cParams;                
                }
                else // Module wasnt loaded, return default .NET RichEdit20 CreateParams.                
                {
                    return base.CreateParams;                
                }
            }
        }

        ~RichTextBoxEx()        
        {
            //Free loaded Library.
            if (mHandle != IntPtr.Zero)            
            {
                FreeLibrary(mHandle);            
            }
        }

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr LoadLibrary(String lpFileName);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool FreeLibrary(IntPtr hModule);    
    }

}
Cheeso
This looks way out of my league. But I will take a look at it once I get comfortable. Thanks!
Animesh