November 14, 2017
There are two main ways to edit code snippets in RTist: using the Code view and the Code editor.
The Code view is mainly intended for browsing code snippets and making small modifications to them. The Code view is updated according to the current selection, it can only show one code snippet at a time and there is only one Code view that can be opened per RTist instance. It is only present in the UML Development perspective by default, and has several tabs showing the code snippets associated with the selected element. Non-empty tabs are displayed first. The header area of the Code view shows the selected model element with a hyperlink for handy navigation to the element in the Project Explorer or diagram. You can also see there whether the code snippet is edited in the model or in a generated file. By default, when the Code view gets focus it tries to load the generated file if it exists. It also has a command to explicitly Load Generated Source in the context menu. If the generated file exists, the Code view enables Eclipse C++ editor functionality such as code completion, navigation commands to other source files and other useful features. It is therefore recommended to always edit a code snippet when the generated file has been loaded, otherwise several editing features will be missing. The Code view displays bookmarks, problem markers and annotation elements associated either with the model element or the file. Once you finish editing in the Code view and switch focus to another window, or press Ctrl+S, changes are committed either to the model or to the generated file.
If you want to compare code snippets or have a full-size editor, you should use the RTist Code editor instead. You can open several Code editors at the same time, and benefit from common features that Eclipse editors provide. The Code editor can be opened from the Code view using the toolbar button Show Source in Editor, or using the same command from the context menu in the Project Explorer. In many cases you can also simply double-click on the model element in the Project Explorer. Try for example to double-click on an operation. The Code editor has information about where the code snippet is edited (model or file) and is designed to have one editor instance per code snippet. There is feature rich functionality available for navigation, code assist, highlighting and so on. It is recommended to save Code editor modifications once you leave the editor area, especially if you work with several editors. There is a preference to automatically save modified files before running a build, it can be found on the UML Development page.
If you have a code editor opened for a code snippet, the Code view will not show this code snippet but instead provide a link to the opened editor. Once the source editor is closed, the Code view will display this code snippet.
There are also other ways to edit code in RTist - using the Eclipse CDT dedicated C/C++ editor, which is opened if you double-click on a generated source file in the Project Explorer. It has the benefit of showing the entire C++ file with multiple code snippets, so you can see the full context where the code snippets are located. And finally, you can edit using an external editor which you can choose according to your needs.
You can learn more recommendations about code editing here. Share your feedback with us by mailing to email@example.com.