euporie.console.tabs.console

Contain the main class for a notebook file.

Functions

add_cmd(**kwargs)

Add a command to the centralized command system.

add_setting(name, default, help_, description)

Register a new config item.

cast(typ, val)

Cast a value to a type.

edit_in_editor(filename[, line_number])

Suspend the current app and edit a file in an external editor.

get_cmd(name)

Get a command from the centralized command system by name.

has_focus(value)

Enable when this buffer has the focus.

load_registered_bindings(*names[, config])

Assign key-bindings to commands based on a dictionary.

register_bindings(bindings)

Update the key-binding registry.

Classes

Buffer([completer, auto_suggest, history, ...])

The core data structure that holds the text and cursor position of the current input line and implements all text manipulations on top of it.

CellOutputArea(json, parent[, style])

An area below a cell where one or more cell outputs can be shown.

Condition(func)

Turn any callable into a Filter.

ConditionalContainer(content, filter)

Wrapper around any other container that can change the visibility.

Console(app[, path, use_kernel_history, ...])

Interactive console.

Event(sender[, handler])

Simple event to which event handlers can be attached. For instance::.

FloatContainer(content, floats[, modal, ...])

Container which can contain another container for the background, as well as a list of floating containers on top of it.

FormattedTextControl([text, style, ...])

Control that displays formatted text.

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

Several layouts, one stacked above/under the other. ::.

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

Kernel input text areas.

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

A Tab which connects to a kernel.

KernelValidator(kernel)

Validate kernel input using a kernel code completeness call.

KeyBindings()

A container for a set of key bindings.

Layout(container[, focused_element])

The layout for a prompt_toolkit Application.

LspCell(id, idx, path, kind, language, text, ...)

An LSP client's representation of a cell.

LspFormatter(lsp, path[, languages])

Format a document using a LSP server.

MsgCallbacks

Typed dictionary for named message callbacks.

PrintingContainer(children[, width, ...])

A container which displays all it's children in a vertical list.

Report([iterable])

Class for storing a diagnostic report.

StdInput(kernel_tab)

A widget to accept kernel input.

UPath(*args[, protocol])

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

Several layouts, one stacked left/right of the other. ::.

ValidationState(value[, names, module, ...])

The validation state of a buffer.

Window([content, width, height, z_index, ...])

Container that holds a control.

partial

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

class euporie.console.tabs.console.Console(app: BaseApp, path: Path | None = None, use_kernel_history: bool = True, connection_file: str = '')

Bases: KernelTab

Interactive console.

An interactive console which connects to a Jupyter kernel.

accept_stdin(buf: Buffer) bool

Accept the user’s input.

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

Prompt the user to select a new kernel.

clear_output(wait: bool = False) None

Remove the last output, optionally when new output is generated.

close(cb: Callable | None = None) None

Close the console tab.

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.

complete(content: dict | None = None) None

Re-render any changes.

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).

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.

interrupt_kernel() None

Interrupt the current Notebook’s kernel.

kernel: Kernel
kernel_died() None

Call when the kernel dies.

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.

lang_file_ext() str

Return the file extension for scripts in the notebook’s language.

property language: str

The language of the current kernel.

load_container() HSplit

Build the main application layout.

async load_history() None

Load kernel history.

async load_lsps() None

Load the LSP clients.

lsp_add_cell(lsp: LspClient) None

Notify the LSP of a new cell.

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.

property lsp_cell: LspCell

Return a LSP cell representation of the current input.

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.

property metadata: dict[str, Any]

Return a dictionary to hold notebook / kernel metadata.

mime_types: ClassVar[set[str]] = {}
name: str | None = None
new_output(output_json: dict[str, Any]) None

Print the previous output and replace it with the new one.

property path_cell: Path

Return the virtual path of the console as a notebook cell.

property path_nb: Path

Return the virtual path of the console as a notebook.

post_init_kernel() None

Run stuff after the kernel is loaded.

pre_init_kernel() None

Run stuff before the kernel is loaded.

prompt(text: str, offset: int = 0, show_busy: bool = False) StyleAndTextTuples

Determine what should be displayed in the prompt of the cell.

refresh(now: bool = True) None

Request the output is refreshed (refresh the whole app).

render_outputs(app: Application[Any]) None

Request that any unrendered outputs be rendered.

report() Report

Return the current diagnostic reports.

report_kernel_error(error: Exception | None) None

Report a kernel error to the user.

reset() None

Reset the state of the tab.

restart_kernel(cb: Callable | None = None) None

Restart the current Notebook’s kernel.

run(buffer: prompt_toolkit.buffer.Buffer | None = None) None

Run the code in the input box.

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

Save the console as a notebook.

set_kernel_info(info: dict) None

Receive and processes kernel metadata.

set_next_input(text: str, replace: bool = False) None

Set the text for the next prompt.

property title: str

Return the tab title.

validate_input(code: str) bool

Determine if the entered code is ready to run.

weight: int = 0