EasyIDE - An IDE for Mathematica


Contrary to what would probably be best practice, I do all of my Mathematica development inside Mathematica itself. To support this I built out a suite of application development tools , a web site builder , a bug tracker , and a documentation writing system . Each of these worked nicely for me separately, but each of these required a palette and each one ran on notebooks, which meant that my screen filled with too many notebooks to keep track of. And then for each of these palettes and systems I had to write new resource finding code based off the palette or some arbitrarily imposed root directory or else provide some other way to specify where things would be found.

In short, it got messy.

Then, in a very relaxing hiatus from Mathematica I did some python development, writing a package for linking Mathematica to python as well as some stuff for coordinate transforms and finite differencing and other little utilities. In doing this I noticed that everything was just…better. Partly this is because python is much nicer to write significant amounts of code in, being a language that actually supports developers and with actual object orientation and modularity. But another significant part of it was in the tools available to me. In particular I had the python plugin to IntelliJ , which is also repackaged as PyCharm . The fact that I had tabbing, plugins (e.g. for Git ), a file browser inside my dev environment, etc. was at once so entirely normal (I used to be a python programmer before switching over to mostly using Mathematica) and at the same time so nice. I then tried to use the very nice and well constructed IntelliJ plugin for Mathematica but it was just too much of a hurdle to lose everything I was used to and liked about writing my code directly in Mathematica.

And that long, unnecessary background is why today we’re gonna look at a Mathematica IDE written and operating entirely within Mathematica.

EasyIDE

Mostly for the rhyme, I called this thing EasyIDE but it is pretty easy to use, too.

Basics

Installation

Install it off the Paclet Server :

<< https://paclets.github.io/PacletServer/Install.wl
PublicPacletInstall["EasyIDE"]

(*Out:*)


 post27-5677831900721146064


Making a New IDE Notebook

This IDE system is also basically just a package and a stylesheet, so it’s pretty easy to get started. Simply go to Format ▸ Stylesheet ▸ EasyIDE ▸ LightMode . It’ll prompt you for a directory to use as the root directory. Here’s a video as an example:

You can play around with the file browser now or the plugin menus in the top right

Notebooks, Packages, and Text Files

As things currently stand, the IDE recognizes three types of files to handle in different ways. The first, of course, are plain notebooks. These can be manipulated like normal. Here’s an example of making and editing a notebook file in the IDE:

Text and package files can be made in the same way–just assign the appropriate file extension.

Each of these files will work basically as a regular file would, except their contents will be saved to their original file on the disk rather than the current NotebookFileName[] .

The File Browser

One of the most useful and intuitive features of this IDE is the file browser it has built in. This allows you to quickly find files inside the active directory. Here’s a screen shot of what that can look like:

post27-1442079965320612466

Each entry in this has a ContextMenu that allows for some file- or directory-specific actions.

Stylesheet / Extension Based Behavior

EasyIDE is built to be extensible. It provides a way to get different behavior depending on what would be useful for the specific type of notebook or file is being fed in. These are controlled in the EasyIDE settings, in particular at EasyIDE ▸ Resources ▸ Settings ▸ Mappings where there are many files that control how these should map. This directory may also be created in $UserBaseDirectory/ApplicationData and the settings there will take precedence over those in the paclet folder itself.

These customizations include stylesheets, toolbars, and what to do when the file browser is active.

Plugins and Toolbars

Probably the best feature of having something like EasyIDE is the ability to hook external code into the IDE and have it give new, more powerful capabilities. To make this easy to work with I added both a plugin system and a toolbar system (although the latter is really just a special case of the first). Plugins appear as either menus–such as the File and Project menus which are themselves just plugins–or as commands under the plugins menu. Currently I already have a decent number of these:

post27-6483075564890356321

All of these add new functionality to the IDE based on code I’d written before. In that screenshot you can also see a toolbar, which exists right below the tabs. This can be stylesheet specific and thus adds an even more targeted way to add functionality to the system. Here’s an example of the four different toolbars I’ve implemented as well as the different stylesheets they go with:

In that you can also see the major downside of putting everything into an IDE: when the files get big (as is the one I’m using to write this post) things can get slower. On the other hand as long as one is only writing code, this is never an issue. And even with a ~12MB file like this things are still more than fast enough to not be frustrating to work with.

Extensions

Styles

EasyIDE was built to be customizable. This holds first and foremost for the stylesheets it works with. Even though currently there is only a set of LightMode styles, as DarkMode style set could be constructed without too much more difficulty. To do this, one would merely have to take the existing LightMode stylesheet, copy it, and make the necessary cosmetic changes. These changes should then propagate reasonably naturally to the extension styles if the inheritance is changed. This is on the TODO list, but if there is a quality existing DarkMode stylesheet to work off that would also make life much easier.

Plugins and Toolbars

These may be hooked in by adding things to EasyIDE ▸ Resources ▸ Settings ▸ Plugins and EasyIDE ▸ Resources ▸ Settings ▸ Toolbars . There are a number of good examples there already.

Miscellaneous Extensions

I had already implemented stuff for creating nice docs, Markdown notebooks, websites, bug tracking, paclet creation, etc. and some of this has made it in as plugins already. More is forthcoming, but for now one can always play with what’s in the Plugins menu. In particular the Git plugin is useful for me as I write and develop.

The EasyIDE API

EasyIDE is just a collection of functions wrapped into a single unit. These were designed to (hopefully) be modular and clean to work with. Eventually all core functionality will also make its way to being attached to a single object, the IDENotebookObject . The API for this is based off of my InterfaceObjects package and is object-oriented. This will be documented in due time, but as a taste here’s what it can look like:

ide = IDENotebookObject[]

(*Out:*)


 post27-2774621243698091573


ide@"Methods"

(*Out:*)

{"Open","Save","Close","SwitchTab","Path","Data","SetData","ToggleFileViewer","AddToolbar","RemoveToolbar","AddStyles","RemoveStyles","GetStylesheet","SetStylesheet","SetProjectDirectory","CreateMessage","CreateDialog"}

These "Methods" are all operations that the IDE notebook referenced to by EvaluationNotebook[] can perform. Here’s an example of creating a message:

ide@"CreateMessage"["Hello!"]

(*Out:*)


 post27-6469651990570110283


post27-316085028871083490

As the IDE grows in sophistication so will the methods the API supports. For now, though, these provide the most direct control that is possible to get with the IDE.