Skip to content

Adding Custom Project Type

Maged Ahmed Rifaat edited this page Aug 23, 2020 · 5 revisions

A new feature in the IDE is the ability to add a new language or project type to the IDE completely through preferences, with further ability to add syntax features through plugins. A great demonstration for this feature is how the language Céu itself was added to the IDE.

Defining the project attributes

The first step for adding your custom language/project type is to define some attributes for the project to be used by the IDE. This can be done in the "preferences.txt" file that is present in the "lib" directory in the installation folder of the IDE.

Around the end of this file you will find the following line:

project-types = ceu, pico-ceu, ceu-arduino, legacy

These are the names of the project types currently supported by the IDE. Let's say we want to add support for the python language, we simply add it in this line:

project-types = python, ceu, pico-ceu, ceu-arduino, legacy

Note that spaces are optional but the name given here is important as we will use it later to define project attributes.

The next step is defining a title for our new project type by adding the following line:

python-title = Python Scripts

Notice how we use the project name we defined earlier with a hyphen followed by the attribute name. This is a pattern that we will use to define the rest of the attributes for this project type. There are a few required attributes to define for your projects which are:

  • title
  • extensions
  • compile

And some optional attributes like:

  • upload
  • run
  • keywords

We already defined the "title" attribute, for the "extensions" attribute we need to add comma separated list of extensions supported by this project type with the main extension first:

python-extensions: py

The "compile" attribute is a little different. For the "compile" attribute, we need to specify the name of a script file (batch file for windows or shell file for linux) and the IDE will run this script file every time the user uses the "Verify" feature in the IDE. Your script will take the full path of the main project file as input so you can use it to compile your project or in the case of of an interpreted language like python you can run a simple syntax check.

python-compile: py_verify.sh

If your project is a runnable script like python you can then go on and add a "run" attribute which, very similar to "compile", takes a script name that will get the full project file path each time the "Run" feature of the IDE is used. Otherwise, if your project is an Arduino-like project where you upload your code to a board you should instead add an "upload" attribute.

python-run: py_run.sh

You can check the Céu shell scripts included with the IDE to see how you could go about implemented such scripts for your own language and how you can fetch missing information in some cases (see ceu-arduino-compiler.sh).

Finally, if you want to add syntax highlighting for your language, you need to specify the name of the keywords file that you should create and put inside the "lib" directory:

python-keywords: py_keywords.txt

Writing this keywords file is as simple as listing the language keywords along with the "category" of each word that the IDE then use to color the keywords accordingly. See "keywords.txt" and "keywords_ceu.txt" for examples on how to do so, as well as the names of those "categories" that the IDE expects.

And that's it! You have added support for python in the IDE and you can now choose this project type the next time you use the IDE and write scripts that will run through your shell scripts in the IDE console, with syntax highlighting and everything!

Advanced Syntax Features

You will notice that Céu has more syntax features in the IDE than simple syntax highlighting. It has features like Auto-indentation, Auto-Formatting and code folding. To implement such features for your new language you will need to write plugins for this purpose. Check the Céu plugins that come with the IDE for how to implement these features. You should be able to get it working with minor modifications to these plugins (namely the regex that determines the start of a block and the end of a block and so on).

Clone this wiki locally