A notebook controller represents an entity that can execute notebook cells. This is often referred to as a kernel.
There can be multiple controllers and the editor will let users choose which controller to use for a certain notebook. The {@linkcode NotebookController.notebookType notebookType}-property defines for what kind of notebooks a controller is for and the {@linkcode NotebookController.updateNotebookAffinity updateNotebookAffinity}-function allows controllers to set a preference for specific notebook documents. When a controller has been selected its {@link NotebookController.onDidChangeSelectedNotebooks onDidChangeSelectedNotebooks}-event fires.
When a cell is being run the editor will invoke the {@linkcode NotebookController.executeHandler executeHandler} and a controller is expected to create and finalize a {@link NotebookCellExecution notebook cell execution}. However, controllers are also free to create executions by themselves.
A notebook controller represents an entity that can execute notebook cells. This is often referred to as a kernel. There can be multiple controllers and the editor will let users choose which controller to use for a certain notebook. The {@linkcode NotebookController.notebookType notebookType}-property defines for what kind of notebooks a controller is for and the {@linkcode NotebookController.updateNotebookAffinity updateNotebookAffinity}-function allows controllers to set a preference for specific notebook documents. When a controller has been selected its {@link NotebookController.onDidChangeSelectedNotebooks onDidChangeSelectedNotebooks}-event fires. When a cell is being run the editor will invoke the {@linkcode NotebookController.executeHandler executeHandler} and a controller is expected to create and finalize a {@link NotebookCellExecution notebook cell execution}. However, controllers are also free to create executions by themselves.
(create-notebook-cell-execution notebook-controller cell)
Create a cell execution task.
Note that there can only be one execution per cell at a time and that an error is thrown if a cell execution is created while another is still active.
This should be used in response to the {@link NotebookController.executeHandler execution handler} being called or when cell execution has been started else, e.g when a cell was already executing or when cell execution was triggered from another source.
Parameters:
cell
: NotebookCell
- The notebook cell for which to create the execution.Returns: NotebookCellExecution
- A notebook cell execution.
Create a cell execution task. _Note_ that there can only be one execution per cell at a time and that an error is thrown if a cell execution is created while another is still active. This should be used in response to the {@link NotebookController.executeHandler execution handler} being called or when cell execution has been started else, e.g when a cell was already executing or when cell execution was triggered from another source. **Parameters:** - `cell`: `NotebookCell` - The notebook cell for which to create the execution. **Returns:** `NotebookCellExecution` - A notebook cell execution.
(description notebook-controller)
The human-readable description which is rendered less prominent.
The human-readable description which is rendered less prominent.
(detail notebook-controller)
The human-readable detail which is rendered less prominent.
The human-readable detail which is rendered less prominent.
(dispose notebook-controller)
Dispose and free associated resources.
Returns: void
Dispose and free associated resources. **Returns:** `void`
(execute-handler notebook-controller)
The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All, Run Selection etc. The execute handler is responsible for creating and managing {@link NotebookCellExecution execution}-objects.
The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All, Run Selection etc. The execute handler is responsible for creating and managing {@link NotebookCellExecution execution}-objects.
(id notebook-controller)
The identifier of this notebook controller.
Note that controllers are remembered by their identifier and that extensions should use stable identifiers across sessions.
The identifier of this notebook controller. _Note_ that controllers are remembered by their identifier and that extensions should use stable identifiers across sessions.
(interrupt-handler notebook-controller)
Optional interrupt handler.
By default cell execution is canceled via {@link NotebookCellExecution.token tokens}. Cancellation
tokens require that a controller can keep track of its execution so that it can cancel a specific execution at a later
point. Not all scenarios allow for that, eg. REPL-style controllers often work by interrupting whatever is currently
running. For those cases the interrupt handler exists - it can be thought of as the equivalent of SIGINT
or Control+C
in terminals.
Note that supporting {@link NotebookCellExecution.token cancellation tokens} is preferred and that interrupt handlers should only be used when tokens cannot be supported.
Optional interrupt handler. By default cell execution is canceled via {@link NotebookCellExecution.token tokens}. Cancellation tokens require that a controller can keep track of its execution so that it can cancel a specific execution at a later point. Not all scenarios allow for that, eg. REPL-style controllers often work by interrupting whatever is currently running. For those cases the interrupt handler exists - it can be thought of as the equivalent of `SIGINT` or `Control+C` in terminals. _Note_ that supporting {@link NotebookCellExecution.token cancellation tokens} is preferred and that interrupt handlers should only be used when tokens cannot be supported.
(label notebook-controller)
The human-readable label of this notebook controller.
The human-readable label of this notebook controller.
(notebook-type notebook-controller)
The notebook type this controller is for.
The notebook type this controller is for.
(on-did-change-selected-notebooks notebook-controller)
(on-did-change-selected-notebooks notebook-controller listener)
(on-did-change-selected-notebooks notebook-controller listener this-args)
(on-did-change-selected-notebooks notebook-controller
listener
this-args
disposables)
An event that fires whenever a controller has been selected or un-selected for a notebook document.
There can be multiple controllers for a notebook and in that case a controllers needs to be selected. This is a user gesture and happens either explicitly or implicitly when interacting with a notebook for which a controller was suggested. When possible, the editor suggests a controller that is most likely to be selected.
Note that controller selection is persisted (by the controllers {@link NotebookController.id id}) and restored as soon as a controller is re-created or as a notebook is {@link workspace.onDidOpenNotebookDocument opened}.
Parameters:
listener
: (e: T) => any
- The listener function will be called when the event happens.this-args
: any
- The this
-argument which will be used when calling the event listener.disposables
: Disposable[] | undefined
- An array to which a {@link Disposable } will be added.Returns: Disposable
- A disposable which unsubscribes the event listener.
An event that fires whenever a controller has been selected or un-selected for a notebook document. There can be multiple controllers for a notebook and in that case a controllers needs to be _selected_. This is a user gesture and happens either explicitly or implicitly when interacting with a notebook for which a controller was _suggested_. When possible, the editor _suggests_ a controller that is most likely to be _selected_. _Note_ that controller selection is persisted (by the controllers {@link NotebookController.id id}) and restored as soon as a controller is re-created or as a notebook is {@link workspace.onDidOpenNotebookDocument opened}. **Parameters:** - `listener`: `(e: T) => any` - The listener function will be called when the event happens. - `this-args`: `any` - The `this`-argument which will be used when calling the event listener. - `disposables`: `Disposable[] | undefined` - An array to which a {@link Disposable } will be added. **Returns:** `Disposable` - A disposable which unsubscribes the event listener.
(set-description! notebook-controller value)
The human-readable description which is rendered less prominent.
The human-readable description which is rendered less prominent.
(set-detail! notebook-controller value)
The human-readable detail which is rendered less prominent.
The human-readable detail which is rendered less prominent.
(set-execute-handler! notebook-controller value)
The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All, Run Selection etc. The execute handler is responsible for creating and managing {@link NotebookCellExecution execution}-objects.
The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All, Run Selection etc. The execute handler is responsible for creating and managing {@link NotebookCellExecution execution}-objects.
(set-interrupt-handler! notebook-controller value)
Optional interrupt handler.
By default cell execution is canceled via {@link NotebookCellExecution.token tokens}. Cancellation
tokens require that a controller can keep track of its execution so that it can cancel a specific execution at a later
point. Not all scenarios allow for that, eg. REPL-style controllers often work by interrupting whatever is currently
running. For those cases the interrupt handler exists - it can be thought of as the equivalent of SIGINT
or Control+C
in terminals.
Note that supporting {@link NotebookCellExecution.token cancellation tokens} is preferred and that interrupt handlers should only be used when tokens cannot be supported.
Optional interrupt handler. By default cell execution is canceled via {@link NotebookCellExecution.token tokens}. Cancellation tokens require that a controller can keep track of its execution so that it can cancel a specific execution at a later point. Not all scenarios allow for that, eg. REPL-style controllers often work by interrupting whatever is currently running. For those cases the interrupt handler exists - it can be thought of as the equivalent of `SIGINT` or `Control+C` in terminals. _Note_ that supporting {@link NotebookCellExecution.token cancellation tokens} is preferred and that interrupt handlers should only be used when tokens cannot be supported.
(set-label! notebook-controller value)
The human-readable label of this notebook controller.
The human-readable label of this notebook controller.
(set-supported-languages! notebook-controller value)
An array of language identifiers that are supported by this controller. Any language identifier from {@linkcode languages.getLanguages getLanguages} is possible. When falsy all languages are supported.
Samples:
// support JavaScript and TypeScript
myController.supportedLanguages = ['javascript', 'typescript']
// support all languages
myController.supportedLanguages = undefined; // falsy
myController.supportedLanguages = []; // falsy
An array of language identifiers that are supported by this controller. Any language identifier from {@linkcode languages.getLanguages getLanguages} is possible. When falsy all languages are supported. Samples: ```js // support JavaScript and TypeScript myController.supportedLanguages = ['javascript', 'typescript'] // support all languages myController.supportedLanguages = undefined; // falsy myController.supportedLanguages = []; // falsy ```
(set-supports-execution-order! notebook-controller value)
Whether this controller supports execution order so that the editor can render placeholders for them.
Whether this controller supports execution order so that the editor can render placeholders for them.
(supported-languages notebook-controller)
An array of language identifiers that are supported by this controller. Any language identifier from {@linkcode languages.getLanguages getLanguages} is possible. When falsy all languages are supported.
Samples:
// support JavaScript and TypeScript
myController.supportedLanguages = ['javascript', 'typescript']
// support all languages
myController.supportedLanguages = undefined; // falsy
myController.supportedLanguages = []; // falsy
An array of language identifiers that are supported by this controller. Any language identifier from {@linkcode languages.getLanguages getLanguages} is possible. When falsy all languages are supported. Samples: ```js // support JavaScript and TypeScript myController.supportedLanguages = ['javascript', 'typescript'] // support all languages myController.supportedLanguages = undefined; // falsy myController.supportedLanguages = []; // falsy ```
(supports-execution-order? notebook-controller)
Whether this controller supports execution order so that the editor can render placeholders for them.
Whether this controller supports execution order so that the editor can render placeholders for them.
(update-notebook-affinity notebook-controller notebook affinity)
A controller can set affinities for specific notebook documents. This allows a controller to be presented more prominent for some notebooks.
Parameters:
notebook
: NotebookDocument
- The notebook for which a priority is set.affinity
: NotebookControllerAffinity
- A controller affinityReturns: void
A controller can set affinities for specific notebook documents. This allows a controller to be presented more prominent for some notebooks. **Parameters:** - `notebook`: `NotebookDocument` - The notebook for which a priority is set. - `affinity`: `NotebookControllerAffinity` - A controller affinity **Returns:** `void`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close