Sublime Blog

Python as an extension language: Not all beer and sunshine

If you're shopping around for an extension language for your project, it's pretty hard to go past Python. Aside from being a very pleasant language to work with, it has a huge selection of libraries, and a user base that's at least as large. Add projects like Boost.Python into that, and you've got a pretty compelling case. However, it's not all beer and sunshine in Python land - at least, not on Windows.

Lets start with the simplest case: Ship python25.dll, and python25.zip (containing the standard libraries) with your application, and provide some means for users to enter Python code.

Golden, right? Not so much. It'll work fine right up until someone with an international version of Windows tries to install your application to a localized version of "C:\Program Files" that contains a unicode character. Then everything falls over.

Oh, you thought Python supported unicode? Well, it does. Sort of. Provided you don't expect to be able to put unicode paths within sys.path, the list of directories python files may be loaded from. Ouch!

There are still options though: you can set sys.path to load from the current directory, and just set the current directory appropriately before making any calls into Python.

Now, let's take a look at loading user supplied plugins from .py files. You could just place them in the same directory that the application is installed to, but that's not a great solution on Vista, as users generally won't have write access to Program Files. A better location is to place them within the Application Data folder, contained within the user's home directory.

This raises some more problems: It's not uncommon for users to have unicode characters in their username, and hence in their Application Data path. So we can't simply add that to sys.path. We also can't use the current directory trick any longer, as there are now two directories to load things from.

For Sublime Text, I've implemented a half way solution: Do some sys.path_hooks mangling to get modules loading from python25.zip, and use the current directory trick for user supplied modules (Drop me an email if you're interested in the code). It's not pretty, but it does work.

Aside from current directory wrangling, there's another option I've yet to try: short path names. Windows has a notion of short path names, where every file has its full path name, and a short one (see GetShortPathName) in 8.3 format for archaic programs. The noteworthy part is that the 8.3 name uses ASCII characters, so they'll be safe to use as Python module paths. There are a few caveats with this approach:

  • Not every file has a short path name. Generation of them may be turned off.
  • Some file systems don't support 8.3 file names: They presumably won't exist on Samba shares, for instance.

It's unfortunate that Python has this limitation. My understanding is that it is not going to be fixed for Python 3.0, though there has been some work in this direction. Despite this, I still think you'd be mad to use anything else as an extension language.

Jon Skinner

Distraction Free Editing

Sometimes, you just want to focus on what you're writing. You don't need toolbars, you don't need tabs, hell, you don't even need menus. Using full screen mode in a standard text editor is a good start, but it's generally not as minimalist as it could be, and the text is all bunched over on one side of the screen.

So what options do you have? If you're on a Mac, you can use WriteRoom, and which has a Windows clone called Dark Room. Other options are PyRoom, JDarkRoom and Vroom. These are all great for editing prose, but none support editing LaTeX, let alone code.

If, like Mark Pilgrim, all this makes you wonder why someone would want a text editor with no features, then I do suggest giving one of them a try, it's a pleasant experience.

Prompted by a suggestion on the forums, the current beta supports this very style. In this setup, there's nothing at all on the screen but your text in the center, and a muted scrollbar on the right. The cursor doesn't even blink. You can think of it as WriteRoom for Windows, with regular expressions, Python plugins and code editing.

Here's a screen shot of it in action:

Extra full screen thumbnail

Note the lack of menu, status bar, toolbar, line numbers, rulers etc.

Unlike multi pane editing, the objective here isn't to fit as much information as possible on the screen, but to block out everything that you don't need right now. It also works seamlessly with multiple monitors, with each one able to edit a different file in a similar fashion.

[Edit: this is included by default in the latest versions of Sublime Text. Press Shift+F11 to try it out for yourself]

Enjoy!

PS., If you're writing the next great literary work, then you may also be interested in the very handy Automatic Backups plugin.

PPS., Did I mention Sublime Text has LaTeX syntax highlighting out of the box?

Jon Skinner

1.03 and Forums

1.03 has just been released, featuring among other things, support for TextMate syntax files. Because of this, many more file types are supported out of the box. The default color scheme has been changed too - enjoy the delicious colors of Monokai. What are you waiting for? Download!

Coinciding with this release, the much requested forum is up now too. Drop by and say hi!

Jon Skinner

ClearType and Documentation

The enthusiasm, support and feedback from 1.0 has been remarkable - thanks everyone! Work is progressing on the next version, you can view the current incarnation on the beta page. Notably, the beta has ClearType support, which has been one of the most heavily requested features.

The first part of the documentation is up too, detailing how Selection works. It's available via the Support page. More to come!

Jon Skinner

1.0!

1.0 is out! Download it and take it for a spin, feedback is more than welcome!

Like any bit of software, it's a long road to release, though in truth it's only the beginning. There's already a long list of features to add, and it's only going to get longer with your feedback.

As feedback comes in, the feature list is going to get re-prioritised and added to, so the sooner you give it a try, the better chance you have of seeing your wish list come true!

Jon Skinner

Regex Syntax Highlighting

(Just a short post while I get the next one ready)

Sometimes its the little things that make the difference. When you're entering a regular expression, you get syntax highlighting in the text box:

You can see in the bottom of the screenshot, the regex operators and character classes are rendered nicely.

Jon Skinner

Anatomy of a Next Generation Text Editor

(This is an introduction to the user interface of Sublime Text, it's the first in a series)

My background is in building tools for games. I've encountered some beautifully designed tools for artists, such as Modo, ArtRage and Silo. At the time I was using Vim in its 16 colour, 80 column glory, and the very colourful Visual Studio. It occurred to me: why couldn't the humble text editor get some of this love?

I've tried to put some of this user interface craftsmanship into Sublime Text. There are three principles I felt would be required:

  • Unobtrusive, minimal chrome. The focus should be on the text, not fourteen different toolbars.
  • Don't obscure the text with dialogs.
  • Use the pixels you've got. Full screen, multi monitor and editing files side by side should all be possible.

Below is a short tour showing how I've applied these rules in building Sublime Text. First, here's the basic day-to-day level of chrome you are presented with:

There's not much there, and it's certainly not yelling at you.

Functionality like find and replace, that would generally be implemented via dialogs, is instead presented as a panel at the bottom of the screen.

The crown jewel, however, is how it works when you start to get serious. The full screen mode does away with a maximum amount of chrome, and works seamlessly with multiple monitor setups. Here you can see Sublime Text running on two monitors, full screen on each, with five files being edited side-by side.

Here's a screenshot of the large monitor in the above photo, editing three files side by side in full screen. (Warning: 2560x1600 pixels ahead!)

Have I missed any principles? Have I adhered to the ones I set? I'd love your thoughts and feedback.

(Subscribe to the blog, so you don't miss part two!)

Jon Skinner

Building a Better Text Editor

The text editor is a humble tool, its purpose distinct and implementation well trodden. There are a lot of people who spend a lot of time working them them: you've probably got one open right now.

I think they can be better.

Furthermore, I've got a fairly strong vision of exactly how they can be better. I left my job as a software engineer at Google to build a company, and a text editor, around this conviction.

I'd like to share my ideas for a better text editor; you'll shortly see the beginning of a series of articles describing just that. Stay tuned!

In the mean time, why not let me know what you think a better text editor should be?

Jon Skinner

Status Update

1 week in. Weather is getting hotter. Code is being written. It's great to be seeing real progress.

To tell the truth, I've previously spent a few weeks working full time on Sublime Text, so this isn't entirely new. I'm addressing some of the bigger areas of work that I haven't had an opportunity to in the past. When you've only got weeknights available, it's harder to justify work that doesn't have an immediate result.

It all comes under the 'Things to do before launch' category, seeing that list get smaller is great.

Jon Skinner

It Pans! It Zooms! It...

December, 2005. I had been kicking around the idea of a 3D accelerated text editor for some time. In my head I could see myself zooming in and out of files like I was in a movie. Gasps from the crowd at the smooth action! I could see myself cackling at the luddites with their tired old scrollbars.

I spent a weekend building a prototype that did just that. It zoomed! It panned! Only, it sucked. It turns out that you can't zoom very far out at all before the text becomes totally illegible. Working on files you can't read wasn't quite what I had in mind!

I did get some insight out of the prototype however, and it gradually morphed into what Sublime Text is today. You'll get to see what that is, when I finally get the bloody thing released later this year.

Jon Skinner
« Newer PostsOlder Posts »