Lightsaber IDE 001: First things first, self-hosting

by Terry Hughes Saturday, April 09, 2011 07:32 PM

Lightsaber IDE

The first thing you'll want to do is get your IDE self-hosted. The best way to figure out what the most important thing to work on is by dogfooding. I also suggest that you use the most basic tools to bootstrap yourself. This way you are more likely to use your IDE rather than the one you usually do.

I've chosen to use notepad with a goal of switching to my IDE ASAP.

So it seems like the first step is to get a form to show up. Obviously, this is rather trivial:

// Program.cs
internal static class Program
    private static void Main()
        Application.Run(new MainForm());

// MainForm.cs
using System.Windows.Forms;

internal class MainForm : Form

I'll need something to type into, a RichTextBox should do for now. I put all the code to add it to the form in MainForm.designer.cs and set it's Dock property to DockStyle.Fill. Next, I need to be able to open and save files. Instead of the traditional File, Edit, ..., Help menus I decided to just have the three items right there as root menus: Save, Open, and New. Some things I ran into: I had to add the STAThread attribute to the Main() method as I wanted to use the built-in OpenFileDialog and SaveFileDialog; the RichTextBox control does not have carriage returns ("\r"), so I had to do a Replace on new lines ("\n") with Environment.NewLine when writing the file; and finally I had to use the Encoding.Default encoding option, so that © et al. will get displayed on the form and saved to the file properly. With that I have a self-hosted IDE that I can begin using.

Comments are closed

About Me

TerryH   I'm a senior software developer currently working on a foreign exchange portfolio management system for a financial company with a bunch of awesome people.


The opinions and viewpoints expressed on this blog are not necessarily those of a cultured, tactful, or well-balanced person. This blog is a product of me, who is solely responsible for its content. Me - Stealing From Smart Developers.

Copyright © 2008-2011 Terry Hughes. All rights reserved.