Skip to content
acken edited this page Feb 5, 2012 · 10 revisions

The Editor Engine is a service that handles integrating with various text editors and exposing it's features through a basic null char terminated text tcp endpoint. It is written in C# and runs with both Microsoft .Net and mono. External applications wanting to integrate with it will connect to this endpoint sending commands. All commands sent will be re-published out to all connected clients in addition to the active plugin.

Locating a running Editor Engine

Every running editor will write a connection file to $TempDir/EditorEngine/[pid].pid where [pid] is the applications process id. The first line of the file is the engines key path while the second line contains the port used by the editor.

Editor plugins

For an editor to be supported it needs a plugin written for it. Every plugin has to conform to the IEditor interface in EditorEngine.Core. To write an editor plugin create a new .Net class library project under src/Plugins. Reference EditorEngine.Core and create a class that implements IEditor. When done make sure that deploy.bat and deploy.sh copies the plugin assembly to ReleaseBinaries/plugins. When asked to initialize an editor the editor engine scans through the plugins directory for an assembly with the same name as passed with the "editor [plugin_name]" command.

Initializing editor

The first command sent to the editor engine should be the "editor [plugin_name]" command. This command will start the editor passed to it. Until this command is sent the editor engine is in an idle state. After the editor is initialized the engine will stay alive for as long as the editor is running.

Testing the engine

To more easily being able to test the editor engine there is a console application called EditorClient. After running deploy start the engine by running ./EditorEngine.exe [key_path]. Wen the engine is running open a new terminal window and cd into the key path. From that path have the EditorClient send a command to the running engine. First launch the editor "[path_to_editor_client]/EditorClient.exe editor [plugin_name]. After that fire off any command you want throgh the EditorClient in the same way.

Editor messages

editor

Initializes editor. The command format is editor editor_name. To launch vim pass "editor vim".

goto

Opens a file on a spesific position. The command format is goto file|line|column. Opening class1.cs at line 10 column 23 would be "goto /path/to/class1.cs|10|23".

setfocus

Sets the initialized editor as the active window.

get-dirty-files

Retrieves opened unsaved files from the editor.

insert

Inserts text into a file. If supported by the editor the editor will handle it. If not it will modify the file on disk. The command format is insert file_containing_text file_to_insert_into|line|column. If file content.txt contains the text you want inserted into targetfile.cs at line 10 column 23 the command would be "insert /path/to/content.txt /path/to/targetfile.cs|10|23".

remove

Removes text from a file. If supported by the editor the editor will handle it. If not it will modify the file on disk. The command format is remove target_file|start_line|start_column end_line|end_column. To remove text from file1.cs from line 10 column 23 to line 13 column 15 the command would be "remove /path/to/file1.cs|10|23 13|15".

replace

Replaces text in a file. If supported by the editor the editor will handle it. If not it will modify the file on disk. The command format is replace file_containing_text file_to_replace_into|line_start|column_start line_end|column_end. As you can see this is just a combination of the insert and remove command.

refactor

Performs a set of insert, remove and replace comands. For each command if supported by the editor the editor will handle it. If not it will modify the file on disk. The command format is refactor file_with_list_of_commands. The file with list of commands contains one line pr. command.

Clone this wiki locally