Files
MeshTerm/meshterm/host/__main__.py
T
Jean-Pierre MartineauandClaude Opus 5.5 b3bf5a6160 The Cardputer Zero gets a console host, and a desktop simulator built on it
The stock image gives an app no text console, so MeshTerm draws its own: the TUI
runs in-process with prompt_toolkit's output feeding a small VT parser, the cells
are drawn in Terminus 6x12 with MeshTerm's marks over it, and keys go in through a
pipe in xterm's spelling. The front end is the only part that differs: framebuffer
and evdev on the device (written ahead of the hardware), a Tk window on the desktop.

Each handheld's glyph inventory is now named by Platform.font, which replaces
ascii_fold; the render-boundary fold derives its accents, emoji, and fallback from
that inventory and quantizes colour only where truecolor is off.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-30 21:08:30 -04:00

55 lines
1.6 KiB
Python

# SPDX-License-Identifier: Apache-2.0
"""``python -m meshterm.host`` — run MeshTerm in the Cardputer Zero's console host.
python -m meshterm.host [--sim [--scale N] | --device] [MESHTERM ARGS...]
``--sim`` (the default off the device) opens the desktop simulator; ``--device`` draws to
the framebuffer and reads the keyboard, and is the default wherever the launcher has named
a framebuffer (``APPLAUNCH_LINUX_FBDEV_DEVICE``). Everything else is passed to MeshTerm as
it would be on a command line — ``--mock`` for the simulated mesh, ``--ble``/``--port``/
``--tcp`` for a companion — with ``--platform cardputer`` supplied by the host.
"""
from __future__ import annotations
import os
import sys
def main(argv: list[str]) -> int:
"""Parse the host's own flags, pass the rest to MeshTerm, and run it."""
from .device import FB_ENV
from .run import run
device = bool(os.environ.get(FB_ENV))
scale = 3
rest: list[str] = []
args = iter(argv)
for arg in args:
if arg == "--sim":
device = False
elif arg == "--device":
device = True
elif arg == "--scale":
scale = max(1, int(next(args, "3")))
else:
rest.append(arg)
if device:
from .device import front_end
else:
from .sim import front_end as sim_front_end
def front_end():
return sim_front_end(scale)
try:
build = front_end()
except FileNotFoundError as missing:
print(f"meshterm host: {missing}", file=sys.stderr)
return 1
return run(rest, build)
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))