A text base user interface for euporie.



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.


Get a command from the centralized command system by name.


Update the key-binding registry.

to_formatted_text(value[, style, auto_convert])

Convert the given value (which can be formatted text) into a list of text fragments.

truncate(ft, width[, style, placeholder, ...])

Truncate all lines at a given length.



A dialog which shows an "about" message.

BaseApp([title, set_title, leave_graphics, ...])

All euporie apps.


A command palette which allows searching the available commands.


Turn any callable into a Filter.

ConditionalContainer(content, filter)

Wrapper around any other container that can change the visibility.


A dialog which allows the user to confirm an action.

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

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


Container class that dynamically returns any Container.


A dialog to show unhandled exceptions.

FileBrowser([path, on_select, on_open, ...])

A file browser.

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

A FloatContainer which uses :py`BoundedWritePosition`s.

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

Control that displays formatted text.

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

Several layouts, one stacked above/under the other.

MenuBar(app, menu_items, grid)

A container to hold the menubar and main application body.

MenuItem([formatted_text, description, ...])

A prompt-toolkit compatible menu item with more advanced capabilities.


A dialog which shows the user a message.


Dialog to warn the user that no installed kernels were found.

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

Interactive notebooks.


Notebook app.


A dialog which prompts the user for a filepath to open.


Interactive help pager.

Pattern(char[, pattern])

Fill an area with a repeating background pattern.


A dialog which prompts the user for a filepath to save the current tab.

SearchBar([search_buffer, vi_mode, ...])

Search mode.


A dialog which allows the user to select a kernel.


Display details of registered key-bindings in a dialog.

SideBar(titles, icons, panels)

A side-bar for the notebook application.

StatusBar([extra_filter, default])

A status bar which shows the status of the current tab.

StatusContainer(body, status)

A container which allows attaching a status function.

TabBarControl(tabs, active[, spacing, ...])

A control which shows a tab bar.

TabBarTab(title, on_activate[, ...])

A named tuple represting a tab and it's callbacks.

TabMode(value[, names, module, qualname, ...])

Define how multiple tabs are displayed.

UPath(*args[, protocol])


A dialog prompting the user to save unsaved changes.

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

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

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

Container that holds a control.

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

Alignment of the Window content.


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

class**kwargs: Any)

Bases: BaseApp

Notebook app.

Interactively edit a notebook file.

Launch the interactive TUI notebook editor, allowing you to run and edit Jupyter notebooks in the terminal.

async cancel_and_wait_for_background_tasks() None

Cancel all background tasks, and wait for the cancellation to complete. If any of the background tasks raised an exception, this will also propagate the exception.

(If we had nurseries like Trio, this would be the __aexit__ of a nursery.)

property cell: Cell | None

Return the currently active cell.

cleanup(signum: int, frame: FrameType | None) None

Restore the state of the terminal on unexpected exit.

cleanup_closed_tab(tab: Tab) None

Remove a tab container from the current instance of the app.


tab – The closed instance of the tab container

close_tab(tab: Tab | None = None) None

Close a notebook tab.


tab – The instance of the tab to close. If None, the currently selected tab will be closed.

property color_depth: ColorDepth

The active ColorDepth.

The current value is determined as follows:

  • If a color depth was given explicitly to this application, use that value.

  • Otherwise, fall back to the color depth that is reported by the Output implementation. If the Output class was created using output.defaults.create_output, then this value is coming from the $PROMPT_TOOLKIT_COLOR_DEPTH environment variable.

color_palette: ColorPalette
context: contextvars.Context | None
cpr_not_supported_callback() None

Called when we don’t receive the cursor position response in time.

create_background_task(coroutine: Coroutine[Any, Any, None]) Task[None]

Start a background task (coroutine) for the running application. When the Application terminates, unfinished background tasks will be cancelled.

Given that we still support Python versions before 3.11, we can’t use task groups (and exception groups), because of that, these background tasks are not allowed to raise exceptions. If they do, we’ll call the default exception handler from the event loop.

If at some point, we have Python 3.11 as the minimum supported Python version, then we can use a TaskGroup (with the lifetime of Application.run_async(), and run run the background tasks in there.

This is not threadsafe.

create_merged_style() BaseStyle

Generate a new merged style for the application.

Using a dynamic style has serious performance issues, so instead we update the style on the renderer directly when it changes in self.update_style


Return a combined style to use for the application

property current_buffer: Buffer

The currently focused Buffer.

(This returns a dummy Buffer when none of the actual buffers has the focus. In this case, it’s really not practical to check for None values or catch exceptions every time.)

property current_search_state: SearchState

Return the current SearchState. (The one for the focused BufferControl.)

dialogs: dict[str, Dialog]
draw(render_as_done: bool = True) None

Draw the app without focus, leaving the cursor below the drawn output.

exit(*args: Any, **kwargs: Any) None

Check for unsaved files before closing.

Creates a chain of close file commands, where the callback for each triggers the closure of the next. The closing process can be cancelled anywhere along the chain.

  • args – Positional arguments

  • kwargs – Key word arguments

focus_tab(tab: Tab) None

Make a tab visible and focuses it.

focused_element: FocusableElement | None
format_title() StyleAndTextTuples

Format the tab’s title for display in the top right of the app.

formatters: list[Formatter]
full_screen: bool
future: Future[_AppResult] | None
get_edit_mode() EditingMode

Return the editing mode enum defined in the configuration.

get_file_tab(path: Path) type[Tab] | None

Return the tab to use for a file path.

get_file_tabs(path: Path) list[type[Tab]]

Return the tab to use for a file path.

get_language_lsps(language: str) list[euporie.core.lsp.LspClient]

Return the approprrate LSP clients for a given language.

get_used_style_strings() list[str]

Return a list of used style strings. This is helpful for debugging, and for writing a new Style.

graphics: WeakSet[Float]
async classmethod interact(ssh_session: PromptToolkitSSHSession) None

Run the app asynchronously for the hub SSH server.

invalidate() None

Thread safe way of sending a repaint trigger to the input event loop.

property invalidated: bool

True when a redraw operation has been scheduled.

property is_done: bool
property is_running: bool

True when the application is currently active/running.


The InputProcessor instance.

classmethod launch() None

Launch the app.

load_container() FloatContainer

Build the main application layout.

classmethod load_input() Input

Create the input for this application to use.

Ensures the TUI app always tries to run in a TTY.


A prompt-toolkit input instance

load_key_bindings() None

Load the application’s key bindings.

load_menu_items() list[]

Load the list of menu items to display in the menu.

classmethod load_output() Output

Create the output for this application to use.

Ensures the TUI app always tries to run in a TTY.


A prompt-toolkit output instance

log_stdout_level: str = 'CRITICAL'
loop: AbstractEventLoop | None
lsp_clients: WeakValueDictionary[str, LspClient]
menus: dict[str, Float]
mouse_limits: WritePosition | None
mouse_position: Point
name: str = 'notebook'
property notebook: euporie.notebook.tabs.notebook.Notebook | None

Return the currently active notebook.

open_file(path: Path, read_only: bool = False, tab_class: type[Tab] | None = None) None

Create a tab for a file.

  • path – The file path of the notebook file to open

  • read_only – If true, the file should be opened read_only

  • tab_class – The tab type to use to open the file

open_files() None

Open the files defined in the configuration.

pager: Pager | None
pause_rendering() None

Block rendering, but allows input to be processed.

The first line prevents the display being drawn, and the second line means the key processor continues to process keys. We need this as we need to wait for the results of terminal queries which come in as key events.

This is used to prevent flicker when we update the styles based on terminal feedback.

post_load() None

Allow subclasses to define additional loading steps.

post_load_callables: list[Callable[[], None]]
pre_run(app: Application | None = None) None

Continue loading the app.

pre_run_callables: list[Callable[[], None]]
print_text(text: AnyFormattedText, style: BaseStyle | None = None) None

Print a list of (style_str, text) tuples to the output. (When the UI is running, this method has to be called through run_in_terminal, otherwise it will destroy the UI.)

  • text – List of (style_str, text) tuples.

  • style – Style class to use. Defaults to the active style in the CLI.


Quoted insert. This flag is set if we go into quoted insert mode.

refresh() None

Reset all tabs.


Render counter. This one is increased every time the UI is rendered. It can be used as a key for caching certain information during one rendering.

reset() None

Reset everything, for reading the next input.

resume_rendering() None

Reume rendering the app.

run(pre_run: Optional[Callable[[], None]] = None, set_exception_handler: bool = True, handle_sigint: bool = True, in_thread: bool = False, inputhook: Optional[Callable[[InputHookContext], None]] = None) _AppResult

A blocking ‘run’ call that waits until the UI is finished.

This will run the application in a fresh asyncio event loop.

  • pre_run – Optional callable, which is called right after the “reset” of the application.

  • set_exception_handler – When set, in case of an exception, go out of the alternate screen and hide the application, display the exception, and wait for the user to press ENTER.

  • in_thread – When true, run the application in a background thread, and block the current thread until the application terminates. This is useful if we need to be sure the application won’t use the current event loop (asyncio does not support nested event loops). A new event loop will be created in this background thread, and that loop will also be closed when the background thread terminates. When this is used, it’s especially important to make sure that all asyncio background tasks are managed through get_appp().create_background_task(), so that unfinished tasks are properly cancelled before the event loop is closed. This is used for instance in ptpython.

  • handle_sigint – Handle SIGINT signal. Call the key binding for Keys.SIGINT. (This only works in the main thread.)

async run_async(pre_run: Callable[[], None] | None = None, set_exception_handler: bool = True, handle_sigint: bool = True, slow_callback_duration: float = 0.5) _AppResult

Run the application.

async run_system_command(command: str, wait_for_enter: bool = True, display_before_text: AnyFormattedText = '', wait_text: str = 'Press ENTER to continue...') None

Run system command (While hiding the prompt. When finished, all the output will scroll above the prompt.)

  • command – Shell command to be executed.

  • wait_for_enter – FWait for the user to press enter, when the command is finished.

  • display_before_text – If given, text to be displayed before the command executes.


A Future object.

search_bar: SearchBar | None
shutdown_lsps() None

Shut down all the remaining LSP servers.

suspend_to_background(suspend_group: bool = True) None

(Not thread safe – to be called from inside the key bindings.) Suspend process.


suspend_group – When true, suspend the whole process group. (This is the default, and probably what you want.)

property syntax_theme: str

Calculate the current syntax theme.

property tab: Tab | None

Return the currently selected tab container object.

tab_bar_tabs() list[euporie.core.widgets.layout.TabBarTab]

Return a list of the current tabs for the tab-bar.

tab_container() AnyContainer

Return a container with all opened tabs.


A layout displaying the opened tab containers.

property tab_idx: int

Get the current tab index.

tabs: list[Tab]

Like Vim’s timeoutlen option. This can be None or a float. For instance, suppose that we have a key binding AB and a second key binding A. If the uses presses A and then waits, we don’t handle this binding yet (unless it was marked ‘eager’), because we don’t know what will follow. This timeout is the maximum amount of time that we wait until we call the handlers anyway. Pass None to disable this timeout.

property title: str

The application’s title.


When to flush the input (For flushing escape keys.) This is important on terminals that use vt100 input. We can’t distinguish the escape key from for instance the left-arrow key, if we don’t know what follows after “x1b”. This little timer will consider “x1b” to be escape if nothing did follow in this time span. This seems to work like the ttimeoutlen option in Vim.

update_edit_mode(setting: Setting | None = None) None

Set the keybindings for editing mode.

update_style(query: TerminalQuery | Setting | None = None) None

Update the application’s style when the syntax theme is changed.


Vi state. (For Vi key bindings.)