euporie.notebook.tabs.edit

Contain a tab for displaying files.

Functions

detect_lexer([text, path, language])

Detect the pygments lexer for a file.

load_registered_bindings(*names[, config])

Assign key-bindings to commands based on a dictionary.

Classes

Dimension([min, max, weight, preferred])

Specified dimension (width/height) of a user control or window.

EditorTab(app[, path, kernel, comms, ...])

Tab class for editing text files.

HSplit(children[, window_too_small, align, ...])

Several layouts, one stacked above/under the other.

Kernel(kernel_tab[, threaded, allow_stdin, ...])

Run a notebook kernel and communicates with it asynchronously.

KernelInput(kernel_tab[, text, multiline, ...])

Kernel input text areas.

KernelTab(app[, path, kernel, comms, ...])

A Tab which connects to a kernel.

MsgCallbacks

Typed dictionary for named message callbacks.

UntitledPath(*args[, protocol])

A path for untitled files, as needed for LSP servers.

class euporie.notebook.tabs.edit.EditorTab(app: BaseApp, path: Path | None = None, kernel: Kernel | None = None, comms: dict[str, Comm] | None = None, use_kernel_history: bool = False)

Bases: KernelTab

Tab class for editing text files.

allow_stdin: bool = True
bg_init = True
change_kernel(msg: str | None = None, startup: bool = False) None

Prompt the user to select a new kernel.

close(cb: Callable | None = None) None

Check if the user want to save an unsaved notebook, then close the file.

Parameters:

cb – A callback to run if after closing the notebook.

comm_close(content: dict, buffers: Sequence[bytes]) None

Close a notebook Comm.

comm_msg(content: dict, buffers: Sequence[bytes]) None

Respond to a Comm message from the kernel.

comm_open(content: dict, buffers: Sequence[bytes]) None

Register a new kernel Comm object in the notebook.

comms: dict[str, Comm]
completers: list[Completer]
container: AnyContainer
property current_input: KernelInput

Return the currently active kernel input, if any.

default_callbacks: MsgCallbacks
file_extensions: ClassVar[dict[str, None]] = {}
focus() None

Focus the tab (or make it visible).

formatters: list[Formatter]
history: History
init_kernel(kernel: Kernel | None = None, comms: dict[str, Comm] | None = None, use_kernel_history: bool = False, connection_file: Path | None = None) None

Set up the tab’s kernel and related components.

inspectors: list[Inspector]
interrupt_kernel() None

Interrupt the current Notebook’s kernel.

kernel: Kernel
property kernel_display_name: str

Return the display name of the kernel defined in the notebook JSON.

property kernel_lang_file_ext: str

Return the display name of the kernel defined in the notebook JSON.

kernel_language: str
property kernel_name: str

Return the name of the kernel defined in the notebook JSON.

kernel_started(result: dict[str, Any] | None = None) None

Task to run when the kernel has started.

property language: str

Return the name of the kernel defined in the notebook JSON.

load() None

Load the text file.

load_container() AnyContainer

Load the “tab“‘s main container.

async load_history() None

Load kernel history.

async load_lsps() None

Load the LSP clients.

lsp_after_save_handler(lsp: LspClient) None

Tell the the LSP we saved a document.

lsp_before_save_handler(lsp: LspClient) None

Tell the the LSP we are about to save a document.

lsp_change_handler(lsp: LspClient) None

Tell the LSP server a file has changed.

lsp_close_handler(lsp: LspClient) None

Tell the LSP we opened a file.

lsp_open_handler(lsp: LspClient) None

Tell the LSP we opened a file.

lsp_update_diagnostics(lsp: LspClient) None

Process a new diagnostic report from the LSP.

lsps: list[LspClient]
property metadata: dict[str, Any]

Return a dictionary to hold notebook / kernel metadata.

mime_types: ClassVar[set[str]] = {'text/*'}
name: str | None = 'Text Editor'
property path_name: str

Return the path name.

property position: str

Return the position of the cursor in the document.

post_init_kernel() None

Load UI and file in background after kernel has inited.

pre_init_kernel() None

Run stuff before the kernel is loaded.

report() Report

Return the current diagnostic reports.

report_kernel_error(error: Exception | None) None

Report a kernel error to the user.

reports: WeakKeyDictionary[LspClient, Report]
reset() None

Reset the state of the tab.

restart_kernel(cb: Callable | None = None) None

Restart the current Notebook’s kernel.

save(path: Path | None = None, cb: Callable | None = None) None

Save the current file.

set_kernel_info(info: dict) None

Handle kernel info requests.

suggester: AutoSuggest
property title: str

Return the tab title.

weight: int = 1