Extending Espresso is easy, thanks to its CSS-based syntax coloring themes, JavaScript-based text actions, and XML-based language definitions.




Language definitions

Text and File Actions


Introduction to extending Espresso

You can extend Espresso using the web languages you already know: CSS, XML, JavaScript, and regular expressions (regex is only necessary if you are adding support for a new language). Because you are using common web languages, you can edit your plug-in's files inside of Espresso. There is even a special EspressoDev plug-in to make editing plug-in XML and JavaScript files easier.

You can currently extend Espresso in two ways:

  1. Themes are normal CSS files, and allow you to change the color and background color of text in the editor
  2. Plug-ins are bundles that can include support for new languages, text actions, new CodeSense definitions, and more. Espresso plug-ins look and act like special files in the Finder, but are actually folders with specially named XML files inside. You can examine the contents of any plug-in by right clicking it in the Finder and choosing Show Package Contents. This can be a great way to learn by example.

Espresso plug-ins use the file extension .espressoplugin (although some older plug-ins may still use the extension .sugar).

Espresso's internal logic

Espresso breaks the text in a document into syntax zones using regular expressions that are defined in a plug-in. Using those syntax zones, Espresso separates the document into logical chunks called Itemizers and colors the syntax zones using the active CSS theme. Itemizers are used to determine what code should be foldable and show up in the Navigator. As you edit the document, different actions and CodeSense will be available depending on the syntax zone your text cursor is inside.

Many aspects of both plug-ins and themes rely on CSS-like selectors that leverage the syntax zones that define the basic parts of the document.

The above functionality breaks down into several basic systems depending on how you want to extend Espresso:

It is also possible to define file actions (that act on files instead of text) or text actions with custom interface elements in Objective-C using the Cocoa API.