Running a 2D model in TRIK Studio from Sublime Text

This article discusses setting up and using the Sublime Text external programming environment to call programs in the TRIK Studio 2D model.

This will allow experienced TRIK Studio users to use all the features of professional text editors and their plugins: static analyzers, autoformatters, color themes.

It also describes how to automatically run the program on several fields, which can be useful for participants in competitions with automated verification systems (for example, the NTI IRS Olympiad).

Preparation

It is assumed that the user is writing a program in an external editor and would like to run this program on one or more fields. Fields can be presented both in the .xml format (more details in the article "2D model tuning"), and in the.qrs format.

  1. Download run_2d_model.cmd file for Windows or run_2d_model.sh for Linux and place it in the folder where TRIK Studio is installed.

  2. Place the fields on which you want to test the program in a separate folder. If the fields are in .xml format, create an empty default.qrs project in this folder.

Setting up Sublime Text

The instruction was tested on Sublime Text 3 (Build 3211). You can download Sublime Text on the official website.

1. Open Sublime Text.

2. ChooseTools → Build System → New Build System.

3. A window with a text file will open. You need to erase everything in it and paste the following code instead, where <path to field dir> is the full path to the folder with the fields:

{
"cmd": ["D:\\TRIKStudio\\run_2d_model.cmd",<path to fields dir>, "$file"],
"selector": "source.js",
"encoding": "windows-1251"
}

4. Edit this file:

  • For Linux, substitute your path to the run_2d_model.sh file instead of the one specified in the code. For example: "cmd": ["/home/admin/TRIKStudio/run_2d_model.sh", “/home/admin/fields/”, "$file"]

  • For Windows, substitute your path to the run_2d_model.cmd file instead of the one specified in the code. For example: "cmd": ["D:\TRIKStudio\run_2d_model.cmd", "D:\Users\Admin\fields", "$file"]

5. Save this text file in the suggested directory <system folder>\Sublime Text 3\Packages\User under the name TRIK.sublime-build.

6. Open your source code in Sublime Text. To launch it, just click Tools → Build or the corresponding key combination (Ctrl + B).

За предложение добавить данную функциональность команда проекта ТРИК благодарит участника Олимпиады НТИ ИРС 2018—2020 гг. Александра Журавлева. For the proposal to add this functionality, the TRIK project team thanks Alexander Zhuravlev, the participant of the NTI IRS Olympiad 2018-2020.