Skip to main content
Extensions can claim files for the editor’s Run button. When the user opens a file and hits Run, Klyx consults every registered FileRunner in descending priority order and delegates to the first runner whose supports returns true. All runner types live in com.klyx.api.data.runner.

FileRunnerRegistry

Resolve the registry from a plugin as a service:
Registering a runner whose id matches an existing one replaces the previous registration.

FileRunner

Implement this interface to handle a specific kind of file:

FileRunRequest

The request handed to every runner when the user hits Run:
The extension convenience property is the most common way to match a file:

FileRunnerContext

Runtime helpers handed to run. Use it to interact with the host:

Running a command in the terminal

runInTerminal opens the terminal screen and executes the command directly — no login shell, prompt, or MOTD, only the command’s stdout/stderr and stdin:
These terminal helpers are only available inside a FileRunner. To run a command or open an interactive shell from anywhere else in your plugin (toolbar action, settings, lifecycle), use TerminalManager.runInTerminal(...) / TerminalManager.openTerminal() instead. See Terminal.

Opening a custom screen

Runners that preview a file can navigate to a screen registered via ScreenRegistry:
To open a screen directly with data — no pre-registration required — pass a composable. The closure captures whatever the screen needs, typically the file being run and its URI:
Screens opened this way are transient: the host auto-unregisters them when the screen is popped, so no cleanup is required. The returned ScreenRegistration lets you remove the screen earlier if needed.

Example

A Python runner registered during onLoad:

Best practices

  • Keep supports cheap: It runs on every file open to decide whether to show the Run button
  • Register with a stable id: Re-registering with the same id replaces the runner
  • Unregister on onUnload: Keep the FileRunnerRegistration and call unregister() to clean up
  • Use runInTerminal for interpreters: It handles opening the terminal, running the command, and setting the working directory