build_tools.syllable_walk_tui.modules.database.screen

Database viewer screen modal component.

This module provides the DatabaseScreen modal for browsing corpus SQLite database contents with pagination and sorting.

Classes

SyllableDetailModal

Modal showing detailed feature breakdown for a syllable.

DatabaseScreen

Modal screen for viewing corpus database contents.

Module Contents

class build_tools.syllable_walk_tui.modules.database.screen.SyllableDetailModal(syllable_data, feature_details, *args, **kwargs)[source]

Bases: textual.screen.ModalScreen

Modal showing detailed feature breakdown for a syllable.

Initialize with syllable data and feature mapping.

BINDINGS = [('escape', 'close', 'Close'), ('enter', 'close', 'Close')]

A list of key bindings.

DEFAULT_CSS = Multiline-String
Show Value
"""
    SyllableDetailModal {
        align: center middle;
    }

    SyllableDetailModal > Vertical {
        width: 50;
        height: auto;
        max-height: 80%;
        background: $surface;
        border: solid $primary;
        padding: 1 2;
    }

    SyllableDetailModal .detail-header {
        text-style: bold;
        color: $accent;
        text-align: center;
        margin-bottom: 1;
    }

    SyllableDetailModal .detail-freq {
        text-align: center;
        margin-bottom: 1;
    }

    SyllableDetailModal .detail-section {
        text-style: bold;
        color: $secondary;
        margin-top: 1;
    }

    SyllableDetailModal .detail-feature {
        padding-left: 2;
    }

    SyllableDetailModal .detail-help {
        text-align: center;
        color: $text-muted;
        margin-top: 1;
    }
    """

Default TCSS.

syllable_data
feature_details
compose()[source]

Create detail modal layout.

action_close()[source]

Close the modal.

class build_tools.syllable_walk_tui.modules.database.screen.DatabaseScreen(db_path=None, patch_name='', *args, **kwargs)[source]

Bases: textual.screen.Screen

Modal screen for viewing corpus database contents.

Displays the syllables table from the corpus.db SQLite database with pagination and sorting by frequency.

Parameters:
  • db_path (pathlib.Path | None) – Path to the corpus.db SQLite database

  • patch_name (str) – Name of the patch (A or B) for display

Keybindings:

Esc: Close screen and return to main view j/k: Navigate rows down/up Enter: Show row details n/l/Right: Next page p/h/Left: Previous page [/]: Cycle sort column (prev/next) f: Toggle sort order (asc/desc) Home: Go to first page End: Go to last page

Initialize database screen.

Parameters:
  • db_path (pathlib.Path | None) – Path to corpus.db file

  • patch_name (str) – Patch identifier for display (A or B)

FEATURE_DETAILS
SORTABLE_COLUMNS = [('syllable', 'Syllable'), ('frequency', 'Freq'), ('starts_with_vowel', 'V→'),...
BINDINGS = [('escape', 'close_screen', 'Close'), ('j', 'cursor_down', 'Down'), ('k', 'cursor_up', 'Up'),...

A list of key bindings.

DEFAULT_CSS = Multiline-String
Show Value
"""
    DatabaseScreen {
        background: $surface;
        padding: 1;
    }

    DatabaseScreen .db-header {
        text-style: bold;
        color: $accent;
        margin-bottom: 1;
    }

    DatabaseScreen .db-meta {
        color: $text-muted;
        margin-bottom: 1;
    }

    DatabaseScreen .db-status {
        dock: bottom;
        height: 1;
        background: $boost;
        padding: 0 1;
    }

    DatabaseScreen .db-help {
        dock: bottom;
        height: 1;
        color: $text-muted;
        padding: 0 1;
    }

    DatabaseScreen DataTable {
        height: 1fr;
    }
    """

Default TCSS.

db_path = None
patch_name = ''
current_page = 1
total_pages = 1
total_rows = 0
page_size = 50
sort_column_index = 1
sort_by = 'frequency'
sort_direction: str = 'DESC'
metadata: dict[str, str]
current_rows: list[dict] = []
compose()[source]

Create database screen layout.

on_mount()[source]

Load data when screen is mounted.

action_close_screen()[source]

Close this screen and return to main view.

action_cursor_down()[source]

Move cursor down one row.

action_cursor_up()[source]

Move cursor up one row.

on_data_table_row_selected(event)[source]

Handle row selection (Enter key) to show details.

action_show_details()[source]

Show detailed feature breakdown for the selected row (fallback).

action_next_page()[source]

Go to next page.

action_prev_page()[source]

Go to previous page.

action_first_page()[source]

Go to first page.

action_last_page()[source]

Go to last page.

action_prev_column()[source]

Cycle to previous sortable column.

action_next_column()[source]

Cycle to next sortable column.

action_toggle_sort()[source]

Toggle sort order (ascending/descending).