Lightsaber IDE 002: Basic improvements

by Terry Hughes Saturday, April 09, 2011 08:15 PM

Lightsaber IDE

Now that I have something that works, let's make it better!

The first thing I'd like to do is make the feedback cycle better. I had setup a build file initially

REM make.cmd
@ECHO OFF

IF EXIST bin RMDIR bin /S /Q
MKDIR bin

"%windir%\Microsoft.NET\Framework\v4.0.30319\csc.exe" /out:bin\DevPad.exe /target:winexe /recurse:src\*.cs /nologo

@ECHO ON

but I soon realized that a simple mistake would lead to me wiping out my IDE and forcing me to go back to notepad or keep a working copy of the IDE around some other place. Also, I would run the make.cmd and then I'd have to run bin\DevPad.exe. I decided to update the build file to stage the executable and only when the compile succeeds do I overwrite the actual IDE.

REM make.cmd
@ECHO OFF

IF EXIST obj RMDIR obj /S /Q
MKDIR obj

"%windir%\Microsoft.NET\Framework\v4.0.30319\csc.exe" /out:obj\DevPad.exe /target:winexe /recurse:src\*.cs /nologo

IF ERRORLEVEL 1 GOTO :EoF

IF EXIST bin RMDIR bin /S /Q
MKDIR bin

COPY obj\*.* bin >> NUL

@ECHO ON

To make it a one step process I added an upgrade file

REM upgrayedd.cmd
@ECHO OFF

CALL make.cmd
@ECHO OFF
START bin\DevPad.exe

@ECHO ON

For tidiness I added a clean script

REM clean.cmd
@ECHO OFF

IF EXIST obj RMDIR obj /S /Q
IF EXIST bin RMDIR bin /S /Q

@ECHO ON

One annoyance I was running into a lot, was getting prompted with the save dialog AND the confirmation that it was okay to overwrite the specified file when I wanted to save. By storing the file name as a variable I'd be able to know if I'm working on an existing file or something new.

I also wanted to make my IDE smarter. If I wasn't careful I could lose unsaved changes. I wrote the logic of remembering if there were usaved changes and prompt for when there were out in its own class, UnsavedChanges and then wired it up inside MainForm. I don't like how UnsavedChanges has to have a IWIn32Window and Action (the Save() method) but it works for now.

The final bits of improvements I wanted to add are to show the current file on the form, set the default size to 800x600, to start maximized, and to set the default font new Font("Consolas", 10, FontStyle.Regular, GraphicsUnit.Point, 0).

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.

Lightsaber IDE 000: A long time ago in a galaxy far, far away....

by Terry Hughes Friday, April 01, 2011 04:45 PM

Lightsaber IDE

So after getting fed up with people complaining about problems with their *favorite* IDE, it occurred to me. Why don't we just make our own? You know, like how a Jedi builds their own lightsaber. Talking about it at work and thinking about it on the commute I came up with a list of big ticket items that would need to be addressed.

  • Editing a file
  • Multiple files
  • Compiling
  • Debugging
  • Test runner
  • Syntax highlighting
  • Find usages
  • Go to definition
  • Intellisense
  • Snippets (prop, propg)
  • Source code integration
  • TeamCity, StyleCop, etx integration
  • ReSharper refactorings
  • Underscoring

While there is a ton more and it's a big task (and most likely a tremendous waste of time) it seems like a fun thing to do, at least for a little while. I also came up with a name, DevPad.

Event Registration

by Terry Hughes Monday, March 24, 2008 02:56 PM

We’ve held two Applied.NET meetings at work. There’s been a lot of interest but I’ve found the hardest part is making the discussion relevant. It’s hard to explain a complex idea using simple examples and in a short amount of time. Luckily, we are starting a new project at work to allow employees to register for events (like training). It will replace an existing system, include new functionality, and be a great opportunity to utilize newer technology. I’m looking forward to getting started as it should help drive home new ideas and expose everyone to a new way of working together.

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.

Disclaimer

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.