Speed of Light

Modern Cocoa Text and a Shell Written for Cocoa

I'm currently in the process of preparing an excellent internal tool developed at Shopify for open source. It's an iOS debugger tool and it's pretty excellent. Those who have seen it have loved it. Soon, we'll be sharing it with the world.

In preparation, today I open sourced two projects developed independently of the tool, but which are used to support it.

The first is Modern Cocoa Text, a Cocoa class for either OS X or iOS which enhances text entry. Just about every app has some form of text entry, but very little has changed in how that works over the past 30 years. We still type out every single character. Shouldn't the computer be smarter and help us out a little bit? A few months ago, I wrote a wishlist for what I hoped to see added to iOS:

If I enter the “ character, you can be sure I'm going to want an ending ” character later on, to end my quotation. Lots of word processors and programming text editors will add the closing quote mark automatically, and then place the cursor in between. If, as is habitual for many typists not used to this nicety, I type an end-quote anyway, skip it and move my cursor for me. The same goes for other character pairs like parentheses (), braces {}, and brackets [].

So Modern Cocoa Text is me putting my code where my mouth is. It's simple code that really makes text entry a lot smarter. If you're a developer, I'd recommend you add it to your app. It's not perfect yet, but pull requests are welcomed.

The second project is JBShellView which leverages the above text functionalities to provide a generic and reusable shell interface for Cocoa apps. It's based off NSTextView and bears a little inspiration (at least getting started) from F-Script's Cocoa shell (although this one wasn't written in 1999).

The demo application for the shell lets you search using duck duck go, just to show you how the shell works when handling network tasks. It's super easy to use in new projects, and can be subclassed, too.