Creating an editor integration


First, let's start with creating a vocabulary for our editor:
"editors.foo" scaffold-basis

Open it up in your favourite editor (or your second favourite.)

To create a new integration, we need to implement the editor protocol:
Define a new class to represent your integration, set in editor-class
Define an editor-command method to construct a command that opens your editor
Define an editor-detached? method that denotes whether your editor should be run in detached mode. This should return t for editors that run in a separate terminal.
Define an editor-is-child? method that tells Factor whether it should be eun as a child process.


Every editor is required to reserve its own editor-class. For example:
SINGLETON: foo

editor-class will be set to this singleton when Factor is set to use your editor of choice. Now, we will define words that will dispatch when the editor class is set to foo.

editor-command takes a file path and line number as strings. Your implementation should form a command that opens the editor to the given line. Many editors have a + option for this. For a simple example of this word's implementation, we can look at editors.gedit:
M: gedit editor-command [ gedit-path , number>string "+" prepend , , ] { } make ;

Here, gedit-path is a word that either pushes the location of gedit from PATH, or uses a user-defined path, set in a global.

Finally, if your editor does not use a GUI, the editor-detached? method must be defined:
M: foo editor-detached? t ;

If your editor has both GUI and TUI frontends, you may want to use more complex logic, or create a variable that the user can set.