Integration with Editors

TeaCode works with most native editors for macOS but it needs plugins for others. We've already made some and we are going to make more, but it's impossible for us to support more editors.

Text Expanding API

We made a simple API that allows other apps to expand text using TeaCode. Basically it's implemented in AppleScript, but we prepared a bash script that calls AppleScript for you. You can get it here.

If you make any plugin, please contact us, so we can share it with other users.

Syntax

sh expand.sh -e file-extension -t text-to-expand
  • file-extension is an extension of the editing file. TeaCode needs it to determine the programming language and set priority for the expanders. If you don't know the extension, just put an empty string.
  • text-to-expand is the text that will be expanded.

Output

The API returns a JSON as an output:

{
    "text": "expanded-text",
    "cursorPosition": 14
}
  • text is a line of text that will be expanded. Please note that you should always enter the whole line.
  • cursorPosition is a cursor position as a number of characters from the beginning of the expanding line

Error Handling

If an error occurs, the output will be null. If TeaCode is not installed, the script will throw an error on error output and you should display a message like: Could not run TeaCode. Please make sure it's installed. You can download the app from https://www.apptorium.com/teacode.

Example

The API returns a JSON as an output. Let's take a look at example:

sh expand.sh -e "swift" -t "helloWorld"

It will return

{
    "text": "private func helloWorld() {\n    \n}",
    "cursorPosition":32
}

where:

  • text contains the text that should replace the line
  • cursorPosition is a destination position of cursor as a number of character from the beginning (which is 0) of the expanding line.

Keyboard Shortcut

TeaCode keyboard-shortcut for native editors works globally. Therefor all the plugins need to use different shortcut. The preferable one is ++e (ctrl+cmd+e).

Sample Plugins

We already made 4 plugins. They are open source and you will find them here:

Questions

If you have any questions, please contact us here or via Slack channel.