Files
MeshTerm/meshterm/ui/tui/__init__.py
T
Jean-Pierre MartineauandClaude Opus 4.8 583be7c4f7 Compose fields: share one UTF-8 byte gauge, and put it on the courier entry
Lift the chat compose bar's byte budget into a reusable gauge and reuse it
wherever a field feeds a size-capped LoRa packet.

- prompt.py gains byte_counter/byte_style and the DM/CHANNEL byte limits, plus
  a byte_limit option on TextScreen: a field so limited rides the shared
  used/limit gauge (right-pinned, green→yellow→orange→red) and blocks Enter
  once the text tops the cap, with a "Too long by n bytes" note. Ui.text and
  session.text thread byte_limit through.
- chat.py drops its private copies and calls the shared byte_counter; the
  limits now come from prompt.py.
- The courier's "Message for …" entry passes byte_limit=DM_BYTE_LIMIT so a
  queued message is gauged and capped the same way a live chat message is.

Also fixes a courier scheduling bug uncovered here: the "When it's next heard"
row carried the value None, indistinguishable from session.select's own cancel
sentinel — backing out of the picker silently queued the message. It now
carries its own WHEN_HEARD sentinel, so Esc cancels and the row means no
schedule.

Full suite green (806).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 21:05:23 -04:00

56 lines
1.5 KiB
Python

"""A small, centralized, reusable full-screen text-UI library.
Built on prompt_toolkit (for the terminal, input, and resize handling) and Rich (for all
content rendering), this package gives the interactive app a consistent, bounded, layered
UI: screens never overflow the terminal, long content scrolls, going deeper stacks dialogs
over a dimmed parent, and Esc always dismisses the current layer.
Public API:
- :class:`~meshterm.ui.tui.session.TuiSession` — the running session and prompt helpers.
- :class:`~meshterm.ui.tui.select.Choice` / :class:`~meshterm.ui.tui.select.Separator`
— items for ``session.select``.
- Screen classes for advanced/custom layers.
"""
from __future__ import annotations
from .overlay import BusyOverlay
from .progress import ProgressScreen
from .prompt import (
CHANNEL_BYTE_LIMIT,
DM_BYTE_LIMIT,
AutocompleteScreen,
ConfirmScreen,
ReconnectDialog,
TextScreen,
TypedConfirmDialog,
byte_counter,
)
from .screen import CANCEL, BusyScreen, Screen, ScrollScreen
from .select import Choice, DeleteRequest, SelectScreen, Separator
from .session import TuiSession
from .spinner import Spinner
__all__ = [
"TuiSession",
"Screen",
"ScrollScreen",
"BusyScreen",
"SelectScreen",
"Choice",
"DeleteRequest",
"Separator",
"TextScreen",
"ConfirmScreen",
"AutocompleteScreen",
"ReconnectDialog",
"TypedConfirmDialog",
"ProgressScreen",
"Spinner",
"BusyOverlay",
"CANCEL",
"DM_BYTE_LIMIT",
"CHANNEL_BYTE_LIMIT",
"byte_counter",
]