MacRabbit

View Espresso Wiki

Welcome! This wiki is mainly intended to document Espresso Sugar development, so you can extend it to do new and cool things. To discuss sugar development, join the forums or pop into IRC!

New to Espresso?

Espresso does not currently have any official documentation, but if you have just started working with Espresso, see our Intro to Espresso for useful resources.

Sugar Documentation Quick Links

  • SugarBasics — the starting point for making Sugars
  • SyntaxThemes — reference for syntax themes (CSS)
  • Syntaxes — reference for language syntax definitions (XML)
  • Selectors — reference for syntax selectors (used throughout Espresso)
  • CodeSense — documentation for adding auto-completion to your Sugars (XML)
  • Itemizers — reference for itemizer recipes (XML)
  • Actions — reference for TextAction and FileAction definitions (XML)
  • Snippets — reference for Sugar-defined snippets (XML)
  • CocoaSugars — reference for the Cocoa API (Objective-C)

Introduction to Espresso’s engine

Espresso has a regular-expressions-based syntax core, much like TextMate (in fact, developers of TextMate language plists will be able to convert them). Espresso reads XML-based syntaxes, then uses those rules to generate a syntax tree for opened text documents. Each syntax zone in that tree has a type identifier (similar to CSS class names in HTML) that can be targeted using CSS-like selectors. This selector targeting is used all over Espresso, for various subsystems like syntax coloring and CodeSense.

That first layer has been done before, so while Espresso’s implementation is quite powerful (especially its selectors), the contextual information usually stays very local and somewhat limited. To remedy that, Espresso layers an “itemizer” above the syntax core. Itemizer definitions group syntax zones into semantical blocks that behave like an “item”, a logical piece of the document.

Itemizing currently brings along two features: the Navigator and great code folding. CSSEdit-like structure listings are now possible for any language, as long as someone takes the time to create a good itemizer definition. Any language offering an itemizer also gets code folding support for free.

This multi-layered design delivers excellent performance while still allowing high-level representations of a document that are actually useful to the user.