Main

Kable

class kable.main.Kable(file_path)[source]

Bases: App

Main Kable application class.

A Textual-based terminal editor with file explorer sidebar, Git-aware status bar, integrated editor, and config persistence.

Parameters:

file_path (Path)

__init__(file_path)[source]

Initialize the application.

Parameters:

file_path (Path) – Path to the file to open initially.

Return type:

None

_load_config()[source]

Load application configuration from disk.

Returns:

Configuration dictionary. Empty dict if loading fails.

Return type:

dict

on_mount()[source]

Called when the application is mounted.

Initializes UI, theme, sidebar state, and editor focus.

Return type:

None

update_clock()[source]

Update the status bar clock display.

Return type:

None

action_quit(should_exit=True)[source]

Quit the application.

Parameters:

should_exit (bool) – If True, exit immediately; otherwise check unsaved changes.

Return type:

None

save_config()[source]

Save configuration to disk.

Return type:

None

action_save()[source]

Save the currently open file.

Return type:

None

check_saved_app(should_exit)[source]

Check for unsaved changes before quitting.

Parameters:

should_exit (bool) – Whether to exit after handling save prompt.

Return type:

None

handle_save_choice(save, should_exit)[source]

Handle save confirmation dialog result.

Parameters:
  • save (bool | None) – Whether user chose to save.

  • should_exit (bool) – Whether to exit after handling.

Return type:

None

action_toggle_explorer()[source]

Toggle file explorer sidebar visibility.

Return type:

None

on_text_area_selection_changed()[source]

Update cursor position in status bar.

Return type:

None

compose()[source]

Build the UI layout.

Returns:

ComposeResult widget tree.

Return type:

Iterable[Widget]

update_status_bar()[source]

Refresh status bar information including branch, filename, and cursor location.

Return type:

None

on_file_explorer_file_clicked(event)[source]

Handle file selection from the file explorer.

Parameters:

event (FileClicked) – Event containing the selected file path.

Return type:

None

kable.main.main()[source]

CLI entry point for Kable.

Parses arguments and launches the application.

Return type:

None