The console host is meshterm.emulator

"Host" already meant two things here: a TCP companion's network host,
and battery="host" for this machine itself. And with a PicoCalc preview
coming, the package is less a console host than an emulator of a
handheld's display: its panel, grid, font, colours and keys. So it is
meshterm.emulator, Platform.console_host is own_display, its desktop
window is window.py (EmulatorWindow) and its device front end
framebuffer.py, since "sim" and "device" now mean the radio simulator and
the device being emulated. MESHTERM_HOST_FONTS is MESHTERM_EMULATOR_FONTS.

The package's own description opens on what it is not: nothing runs the
handheld's processor or operating system; it mimics the display's
constraints so the window obeys the device's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5.5 committed 2026-10-04 14:03:55 -04:00
1 parent 8b742ea270
commit 50ea38faea
22 files changed
+114 -105

No files matched your search

+10 -10
View File
@@ -278,7 +278,7 @@ deliberately, one at a time, and say why in the code.
at its body's indent, side by side, wrapping onto a new band when the line is full
(`qr.qr_strip`). A picked message keeps the codes under it in view. Where the font
draws braille solid (`Platform.solid_braille`: the PicoCalc's built fonts, the
Cardputer's console host, `host/font.BRAILLE`) every code — share screen, page fence
Cardputer's emulator, `emulator/font.BRAILLE`) every code — share screen, page fence
and chat alike — is drawn in
**braille**, one module a dot, eight a cell (`qr._GRID`), so the contact card is 29
cells by 15 rows there and shares the 53×26 panel with its URL at the standard fit.
@@ -634,7 +634,7 @@ derived sweep that runs **every** registered command twice, once plain and once
One codebase, three flavours: **regular** (desktop/ssh, 72 cols, truecolor, emoji),
**picocalc-lyra** (the PicoCalc's 53×26/53×40 framebuffer console, 16 palette slots, a
512-glyph font, no emoji), and **cardputer-zero** (M5Stack's Cardputer Zero, 53×14 in 6×12
cells on a 320×170 panel a console host paints itself, truecolor, no emoji — hardware not
cells on a 320×170 panel MeshTerm paints itself, truecolor, no emoji — hardware not
yet in hand, so it is chosen by flag only).
A frozen `Platform` spec (`meshterm/platforms.py`) resolves
once at boot; consumers bind at platform-switch time via `platforms.on_platform` — never
@@ -717,19 +717,19 @@ branch on the platform per frame, and never `from meshterm.platforms import PLAT
assuming F1–F5. Both decks having five slots is a coincidence, not a rule. The
Cardputer's lane is **Fn+4…8** (F4–F8), never the bare digits, since a digit must stay a
digit where the app takes typing; Shift with them arrives as F16–F20 (xterm's encoding,
which the console host copies). Its chips are laid out exactly as the PicoCalc's — key
which the emulator copies). Its chips are laid out exactly as the PicoCalc's — key
caption, 9-cell chip, 2-cell gaps — captioned F4–F8 in both banks, white on the fn key's
orange-red (a step darker than the print, same hue, so the white holds 4:1), and white on
dark blue while Shift is held.
- **The Cardputer draws its own pixels** (`meshterm/host/`): the stock image leaves an app
no text console, only the framebuffer and the keyboard's event device. The console host
- **The Cardputer draws its own pixels** (`meshterm/emulator/`): the stock image leaves an app
no text console, only the framebuffer and the keyboard's event device. The emulator
runs the ordinary TUI in-process — prompt_toolkit's app session pointed at a fixed 53×14
output whose bytes feed the host's own VT parser (`host/vt.py`), and a pipe the host
types into (`host/keys.py`, xterm's spelling, so Shift+F4–F8 parse as F16–F20) — then
draws the cells in Terminus 6×12 with MeshTerm's marks over it (`host/font.py`). The
output whose bytes feed the host's own VT parser (`emulator/vt.py`), and a pipe the host
types into (`emulator/keys.py`, xterm's spelling, so Shift+F4–F8 parse as F16–F20) — then
draws the cells in Terminus 6×12 with MeshTerm's marks over it (`emulator/font.py`). The
front end is the only part that differs: the framebuffer and evdev on the device
(`host/device.py`, written ahead of the hardware), a Tk window on the desktop
(`host/sim.py`): `python -m meshterm.host --mock`, after
(`emulator/framebuffer.py`, written ahead of the hardware), a Tk window on the desktop
(`emulator/window.py`): `python -m meshterm.emulator --mock`, after
`python scripts/cardputer-zero/fetch-terminus.py` once. Its glyph contract is
`fontset.CARDPUTER_ZERO_CODEPOINTS`, named by `Platform.font` as the PicoCalc's is; the fold
derives everything from the platform's font (accents, emoji, the `?` net) and quantizes
+1 -1
View File
@@ -74,7 +74,7 @@ python scripts/cardputer-zero/fetch-terminus.py
and start the simulator:
```bash
python -m meshterm.host --mock
python -m meshterm.emulator --mock
```
Point `MESHTERM_HOME` at an empty folder first, so the simulated radio's made-up nodes
+1 -1
View File
@@ -411,7 +411,7 @@ def _offer_a_console_that_can_draw_meshterm(console: Console, prefs: Preferences
"""
from .ui.termfont import classic_console
if get_platform().console_host:
if get_platform().own_display:
return False
if not classic_console() or prefs.get("console_setup") == "off":
return False
+31
View File
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: Apache-2.0
"""The emulator: MeshTerm drawing a handheld's display itself, on the device or in a window.
**Not a strict emulator.** Nothing here runs the handheld's processor or its operating
system: MeshTerm runs as itself, on whatever machine runs this. What is reproduced is the
device's *display and keyboard* — its panel's pixel size, the character grid it divides
into, the font every glyph is drawn in, the colours it can show and how bold changes them,
and the keys that drive the F-key lane — so the screen in the window obeys the same
constraints the device's would. It mimics the display; it doesn't emulate the machine.
It began as the Cardputer Zero's *console host* — the program a text app runs inside — and
on that device it is still exactly that.
The Cardputer Zero has no text console an app may use: its launcher owns the screen, the
kernel's framebuffer console is switched off, and a store app may not run as root to
switch it back. What an app *does* get is the framebuffer itself and the keyboard's event
device. So MeshTerm brings its own terminal: this package runs the ordinary TUI in-process,
with prompt_toolkit writing to a fixed-size output whose bytes go to a small VT parser
(:mod:`.vt`) rather than to any terminal, and reading from a pipe this package types keys
into (:mod:`.keys`). The parsed cell grid is drawn into pixels with a 6×12 bitmap font
(:mod:`.font`, :mod:`.raster`), and the pixels go to one of two front ends:
* on the Cardputer Zero, the framebuffer the launcher hands over, with keys from the
keyboard's event device (:mod:`.framebuffer`);
* on a desktop, a window drawing the device's panel scaled up, with keys from the desktop
keyboard (:mod:`.window`) — the device's own code path everywhere except the two ends.
Nothing in the TUI knows it is emulated. The session already takes its input and output
from prompt_toolkit's app session wherever its own terminal wrappers are off, which they
are on these platforms, so this package only has to set that session up and call the CLI
the way a shell would (:mod:`.run`).
"""
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
"""``python -m meshterm.host`` — run MeshTerm in the Cardputer Zero's console host.
"""``python -m meshterm.emulator`` — run MeshTerm in the Cardputer Zero's emulator.
python -m meshterm.host [--sim [--scale N] | --device] [MESHTERM ARGS...]
python -m meshterm.emulator [--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
@@ -17,8 +17,8 @@ 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
"""Parse the emulator's own flags, pass the rest to MeshTerm, and run it."""
from .framebuffer import FB_ENV
from .run import run
device = bool(os.environ.get(FB_ENV))
@@ -35,9 +35,9 @@ def main(argv: list[str]) -> int:
else:
rest.append(arg)
if device:
from .device import front_end
from .framebuffer import front_end
else:
from .sim import front_end as sim_front_end
from .window import front_end as sim_front_end
def front_end():
return sim_front_end(scale)
@@ -45,7 +45,7 @@ def main(argv: list[str]) -> int:
try:
build = front_end()
except FileNotFoundError as missing:
print(f"meshterm host: {missing}", file=sys.stderr)
print(f"meshterm emulator: {missing}", file=sys.stderr)
return 1
return run(rest, build)
@@ -1,16 +1,16 @@
# SPDX-License-Identifier: Apache-2.0
"""The 6×12 bitmap font the console host draws cells in.
"""The 6×12 bitmap font the emulator draws cells in.
Terminus at 12 pixels is the base: it is the PicoCalc's base too, so the two handhelds
read alike, and at 1,356 glyphs it covers everything MeshTerm draws on this platform but a
handful of its own marks. The host is not a kernel console, so nothing caps the glyph count
handful of its own marks. The emulator is not a kernel console, so nothing caps the glyph count
at 512 — no donor slots, no folding braille away. MeshTerm's marks are drawn over the base
from the same pixel art the PicoCalc's font build uses (:data:`MARKS`), so ``★``, ``❯``,
``⚿`` and the rest look the same on both devices; and so is its braille (:data:`BRAILLE`),
solid tiles where Terminus draws the dots apart.
Terminus is licensed under the SIL Open Font License, so it is never shipped inside
MeshTerm: the host loads it from a BDF file on the machine (:func:`find_font`). On the
MeshTerm: the emulator loads it from a BDF file on the machine (:func:`find_font`). On the
desktop, ``scripts/cardputer-zero/fetch-terminus.py`` puts the two 12-pixel BDFs, with their
licence, where :func:`find_font` looks.
"""
@@ -31,8 +31,8 @@ CELL_H = 12
REGULAR_BDF = "ter-u12n.bdf"
BOLD_BDF = "ter-u12b.bdf"
#: Where a font lives when ``MESHTERM_HOST_FONTS`` names no other directory.
FONT_ENV = "MESHTERM_HOST_FONTS"
#: Where a font lives when ``MESHTERM_EMULATOR_FONTS`` names no other directory.
FONT_ENV = "MESHTERM_EMULATOR_FONTS"
def _art(rows: list[str]) -> bytes:
@@ -241,13 +241,13 @@ def build_font(regular: dict[int, bytes], bold: dict[int, bytes] | None = None)
def font_dir() -> Path:
"""Where :func:`find_font` looks: ``$MESHTERM_HOST_FONTS``, else ``fonts`` in the config dir."""
"""Where :func:`find_font` looks: ``$MESHTERM_EMULATOR_FONTS``, else the config ``fonts``."""
override = os.environ.get(FONT_ENV, "").strip()
return Path(override) if override else default_config_dir() / "fonts"
def find_font() -> Font:
"""Load the host font from :func:`font_dir`.
"""Load the emulator's font from :func:`font_dir`.
Raises:
FileNotFoundError: There is no regular face there, with how to fetch one.
File renamed without changes.
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
"""Keys to the bytes a terminal sends for them — what the console host types into MeshTerm.
"""Keys to the bytes a terminal sends for them — what the emulator types into MeshTerm.
Both ends of the host meet here: the device reads key codes off the keyboard's event
device, the simulator reads them off a desktop window, and each turns its own events into
Both front ends meet here: the device reads key codes off the keyboard's event
device, the window reads them off the desktop, and each turns its own events into
a :class:`Key` for :func:`encode` to spell the way xterm does. xterm's spelling is the
contract because it is what prompt_toolkit parses, and what a desktop terminal running
``--platform cardputer-zero`` sends too, so the TUI cannot tell the three apart:
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
"""Cells to pixels: the panel the console host shows, drawn from a :class:`~.vt.Terminal`.
"""Cells to pixels: the panel the emulator shows, drawn from a :class:`~.vt.Terminal`.
The panel is 320×170; 53 columns of 6 pixels and 14 rows of 12 leave a two-pixel margin
right and bottom, which this splits evenly so the grid sits centred. Pixels are packed
@@ -1,9 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
"""Run MeshTerm inside the console host: the TUI unchanged, its terminal ours.
"""Run MeshTerm inside the emulator: the TUI unchanged, its terminal ours.
:func:`run` builds the three pieces every host shares — the :class:`~.vt.Terminal` the
:func:`run` builds the three pieces every front end shares — the :class:`~.vt.Terminal` the
TUI's bytes land in, a :class:`HostOutput` prompt_toolkit writes to, and a pipe input the
host's keys go into — sets them as prompt_toolkit's app session, and calls the ordinary
the keys go into — sets them as prompt_toolkit's app session, and calls the ordinary
CLI with ``--platform cardputer-zero`` exactly as a shell would. A *front end* is the part that
differs: where the pixels go and where the keys come from. It is handed the terminal, the
lock that guards it and a way to type, starts whatever threads it needs, and is told each
@@ -73,10 +73,10 @@ class _Sink:
return True
def fileno(self) -> int:
raise OSError("the console host's output has no file descriptor")
raise OSError("the emulator's output has no file descriptor")
def host_output(
def panel_output(
terminal: Terminal, lock: threading.Lock, on_frame: Callable[[], None]
) -> Vt100_Output:
"""A prompt_toolkit output drawing into ``terminal``: fixed size, 24-bit colour."""
@@ -91,7 +91,7 @@ def host_output(
class FrontEnd(Protocol):
"""Where a host's pixels go and its keys come from."""
"""Where the pixels go and its keys come from."""
def frame_ready(self) -> None:
"""A complete frame has landed in the terminal; draw it when convenient."""
@@ -105,7 +105,7 @@ FrontEndFactory = Callable[[Terminal, threading.Lock, Callable[[str], None]], Fr
def run(argv: Sequence[str], front_end: FrontEndFactory) -> int:
"""Run the MeshTerm CLI with ``argv`` inside the host, drawn by ``front_end``.
"""Run the MeshTerm CLI with ``argv`` inside the emulator, drawn by ``front_end``.
Returns:
The CLI's exit status.
@@ -121,7 +121,7 @@ def run(argv: Sequence[str], front_end: FrontEndFactory) -> int:
reply=pipe.send_text,
)
end = front_end(terminal, lock, pipe.send_text)
output = host_output(terminal, lock, end.frame_ready)
output = panel_output(terminal, lock, end.frame_ready)
try:
with create_app_session(input=pipe, output=output):
# Standalone, as a shell would run it: the CLI reports its own errors and
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
"""The terminal the console host draws: a VT byte stream parsed into a grid of cells.
"""The terminal the emulator draws: a VT byte stream parsed into a grid of cells.
Small on purpose. Its one producer is MeshTerm itself — prompt_toolkit's ``Vt100_Output``
and the session's own fast row writer — so it understands what those emit and the handful
@@ -11,7 +11,7 @@ whole escape sequence, never part of one — so an unknown sequence can never le
parameters onto the screen as text.
The grid is the source of truth for the pixels: :class:`Terminal` records which rows
changed since the host last drew (:meth:`Terminal.take_dirty`), so a keystroke that moves
changed since the emulator last drew (:meth:`Terminal.take_dirty`), so a keystroke that moves
the highlight one row repaints two rows of the panel, not fourteen.
"""
@@ -53,7 +53,7 @@ Cell = tuple[str, Style]
_BLANK: Cell = (" ", PLAIN)
#: A conventional 16-colour palette, for a host that passes none of its own.
#: A conventional 16-colour palette, for an emulator that passes none of its own.
_DEFAULT_PALETTE: tuple[RGB, ...] = (
(0, 0, 0), (205, 0, 0), (0, 205, 0), (205, 205, 0),
(0, 0, 238), (205, 0, 205), (0, 205, 205), (229, 229, 229),
@@ -123,7 +123,7 @@ class Terminal:
self._params = ""
self._dirty: set[int] = set(range(rows))
# --- the grid, as the host reads it ------------------------------------------------
# --- the grid, as the emulator reads it ------------------------------------------------
def _fresh_screen(self) -> list[list[Cell]]:
return [[_BLANK] * self.cols for _ in range(self.rows)]
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
"""The desktop simulator: the Cardputer Zero's panel in a window, keys from the desktop.
"""The emulator's desktop window: the device's panel in a window, keys from the desktop.
Everything between the two ends is the device's own code — the terminal, the font, the
rasterizer, the key encoding — so what the window shows is the panel's pixels, scaled up
@@ -79,7 +79,7 @@ def key_from_tk(keysym: str, char: str, state: int) -> Key | None:
return None
class Simulator:
class EmulatorWindow:
"""A window showing the panel, typing the desktop's keys into the TUI."""
def __init__(
@@ -212,15 +212,15 @@ class Simulator:
def front_end(scale: int = 3):
"""The simulator as a :data:`~.run.FrontEndFactory`, loading the host font first."""
"""The window as a :data:`~.run.FrontEndFactory`, loading the emulator's font first."""
from .font import find_font
font = find_font()
def build(terminal: Terminal, lock: threading.Lock, type_text: Callable[[str], None]):
return Simulator(terminal, lock, type_text, font=font, scale=scale)
return EmulatorWindow(terminal, lock, type_text, font=font, scale=scale)
return build
__all__ = ["Simulator", "front_end", "key_from_tk"]
__all__ = ["EmulatorWindow", "front_end", "key_from_tk"]
-23
View File
@@ -1,23 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
"""The console host: MeshTerm drawing its own pixels, for a panel no terminal runs on.
The Cardputer Zero has no text console an app may use. Its launcher owns the screen, the
kernel's framebuffer console is switched off, and a store app may not run as root to
switch it back. What an app *does* get is the framebuffer itself and the keyboard's event
device. So MeshTerm brings its own terminal: this package runs the ordinary TUI in-process,
with prompt_toolkit writing to a fixed 53×14 output whose bytes go to a small VT parser
(:mod:`.vt`) rather than to any terminal, and reading from a pipe the host writes keys into
(:mod:`.keys`). The parsed cell grid is drawn into pixels with a 6×12 bitmap font
(:mod:`.font`, :mod:`.raster`), and the pixels go wherever the host is showing them:
* on the device, the framebuffer the launcher hands over, with keys from the keyboard's
event device (:mod:`.device`);
* on a desktop, a window drawing the same 320×170 panel scaled up, with keys from the
desktop keyboard (:mod:`.sim`) — the simulator, which is the device's own code path
everywhere except the two ends.
Nothing in the TUI knows it is hosted. The session already takes its input and output
from prompt_toolkit's app session wherever its own terminal wrappers are off, which they
are on this platform, so the host only has to set that session up and call the CLI the
way a shell would (:mod:`.run`).
"""
+15 -14
View File
@@ -153,10 +153,11 @@ class Platform:
battery: Which source feeds the header's battery gauge — ``"companion"`` (read
from the connected MeshCore device) or ``"host"`` (the PicoCalc's own sysfs
``power_supply`` driver, confirmed present in P0). Wired in P5.
console_host: Whether the screen is drawn by MeshTerm's own console host
(:mod:`meshterm.host`) rather than a terminal — where the app is its own
terminal, nothing about the one it was started from (a classic Windows console
to move out of, a font to offer) is its business.
own_display: Whether MeshTerm draws this display itself (:mod:`meshterm.emulator`)
rather than running in a terminal — where the app is its own terminal, nothing
about the one it was started from (a classic Windows console to move out of, a
font to offer) is its business. True on the Cardputer Zero, whose launcher gives
an app no console; and for any platform while the emulator shows it in a window.
modifier_watch: The keyboard whose Shift state the optional evdev watcher follows,
flipping the displayed F-key lane live while Shift is held — a case-insensitive
substring of the input device's name, or ``""`` to leave the watcher off.
@@ -185,7 +186,7 @@ class Platform:
tick_s: float
spinner_tick_s: float
battery: str
console_host: bool
own_display: bool
modifier_watch: str
@property
@@ -216,7 +217,7 @@ REGULAR = Platform(
tick_s=1.0,
spinner_tick_s=0.12,
battery="companion",
console_host=False,
own_display=False,
modifier_watch="",
)
@@ -248,7 +249,7 @@ PICOCALC_LYRA = Platform(
tick_s=2.0,
spinner_tick_s=0.5,
battery="host",
console_host=False,
own_display=False,
modifier_watch="picocalc",
)
@@ -259,11 +260,11 @@ PICOCALC_LYRA = Platform(
#:
#: The same 53 columns as the PicoCalc, which is why most of its flavour carries over; the
#: new constraint is rows. It has its own F-key lane deck (Fn+4…8, chips centred over their
#: keys), dealing the PicoCalc's lanes for now (JP, 2026-09-30). The panel is drawn by a
#: console host that paints RGB565 pixels itself, so it is not held to a 16-slot palette
#: keys), dealing the PicoCalc's lanes for now (JP, 2026-09-30). MeshTerm draws the panel
#: itself in RGB565 (:mod:`meshterm.emulator`), so it is not held to a 16-slot palette
#: (``truecolor``). Provisional until measured on the device: the cadences, taken from the
#: PicoCalc; ``effects`` off; and the battery, read from the companion until the host's
#: gauge (a BQ27220) has a known ``power_supply`` name.
#: PicoCalc; ``effects`` off; and the battery, read from the companion until the device's
#: own gauge (a BQ27220) has a known ``power_supply`` name.
CARDPUTER_ZERO = Platform(
name="cardputer-zero",
readable_cols=53,
@@ -282,15 +283,15 @@ CARDPUTER_ZERO = Platform(
emoji=False,
font="cardputer-zero",
truecolor=True,
# The console host draws its own braille, as the PicoCalc's built fonts do: solid
# tiles, no gap between dots (meshterm/host/font.py, BRAILLE).
# The emulator draws its own braille, as the PicoCalc's built fonts do: solid
# tiles, no gap between dots (meshterm/emulator/font.py, BRAILLE).
solid_braille=True,
url_codes=False,
effects=False,
tick_s=2.0,
spinner_tick_s=0.5,
battery="companion",
console_host=True,
own_display=True,
modifier_watch="tca8418c",
)
+2 -2
View File
@@ -50,7 +50,7 @@ _shift_down = False
_thread: threading.Thread | None = None
#: The session's repaint request, kept from :func:`start` even where no input device was
#: found, so a Shift report from the console host (:func:`report_shift`) still repaints.
#: found, so a Shift report from the emulator (:func:`report_shift`) still repaints.
_on_change: Callable[[], None] | None = None
#: How long a resolved F6–F10 keycode keeps :func:`shift_down` latched ``True`` after the
@@ -80,7 +80,7 @@ def shift_down() -> bool:
def report_shift(down: bool) -> None:
"""Set the Shift state from a source that knows it first-hand, and repaint on a change.
The console host reads the keyboard itself — the simulator's window, the device's event
The emulator reads the keyboard itself — the simulator's window, the device's event
stream — so it knows when Shift goes down before any F-key arrives, and tells the lane
here rather than leaving a second reader to find the same keyboard.
"""
+2 -2
View File
@@ -65,12 +65,12 @@ def in_font(char: str) -> bool:
return ord(char) in FONT_CODEPOINTS
#: The Cardputer Zero's inventory: what its console host draws (:mod:`meshterm.host.font`)
#: The Cardputer Zero's inventory: what its emulator draws (:mod:`meshterm.emulator.font`)
#: — Terminus 4.49's 12-pixel face, every one of its 1,356 glyphs, with MeshTerm's own
#: marks drawn over it and ``⋯`` aliased onto the ellipsis, as on the PicoCalc. No 512-glyph
#: cap here, so braille, the powerline chevrons and accented Latin are all simply present.
#: Generated from ``ter-u12n.bdf`` plus the host's ``MARKS`` and ``ALIASES``; if either
#: changes, this table moves in the same commit (``tests/test_console_host.py`` checks the
#: changes, this table moves in the same commit (``tests/test_emulator.py`` checks the
#: marks, and the font itself wherever it is installed).
# fmt: off
CARDPUTER_RANGES: tuple[tuple[int, int], ...] = (
+1 -1
View File
@@ -769,7 +769,7 @@ def _glyph_compact(icon: str) -> str:
# -- the render-boundary fold (the handhelds) ------------------------------------------
#: The active platform's glyph inventory (``Platform.font``), bound in :func:`_bind`: the
#: PicoCalc's 512-glyph console font, or what the Cardputer's console host draws.
#: PicoCalc's 512-glyph console font, or what the Cardputer's emulator draws.
_FOLD_FONT: frozenset[int] = FONT_CODEPOINTS
#: What may survive the fold: every font codepoint, plus the C0 controls the rendered
+1 -1
View File
@@ -287,7 +287,7 @@ PICOCALC_LYRA_DECK = LaneDeck(
#: The Cardputer Zero's number keys 4-8, which sit right under the display: Fn+4..8 are
#: F4-F8, never the bare digits, since a digit must stay a digit on a screen that takes
#: typing (JP, 2026-09-30). The keyboard driver sends Shift as a key of its own, and the
#: console host encodes Shift+Fn+4..8 the way xterm encodes Shift+F4..F8, which
#: emulator encodes Shift+Fn+4..8 the way xterm encodes Shift+F4..F8, which
#: prompt_toolkit reads as F16-F20 — so a desktop terminal with ``--platform cardputer-zero``
#: drives the same bank. The chips are laid out exactly as the PicoCalc's — the key's
#: caption leading a 6-cell label, nine cells a chip, two between (JP, 2026-09-30) — and
+1 -1
View File
@@ -130,7 +130,7 @@ _KEY_ACTIONS: dict[Any, str] = {
Keys.BackTab: "shift_tab",
# The function keys, for a handheld's F-key lane. All of them, since which keycodes
# drive the lane is the platform's deck's business, not this table's: the PicoCalc's
# MCU sends its Shift bank as F6–F10, the Cardputer's console host sends Shift+F4..F8
# MCU sends its Shift bank as F6–F10, the Cardputer's emulator sends Shift+F4..F8
# as xterm does, which prompt_toolkit reads as F16–F20. The session resolves them
# against the top screen's lane in _dispatch; a key the deck doesn't use, or a
# platform without a lane, resolves to nothing and falls away. Alt+Fn is the kernel's
+2 -2
View File
@@ -5,7 +5,7 @@
Terminus is licensed under the SIL Open Font License, so MeshTerm never ships it: this
downloads the upstream release, checks it is the archive it should be, and extracts
``ter-u12n.bdf``, ``ter-u12b.bdf`` and the licence beside them into the directory the host
reads (``$MESHTERM_HOST_FONTS``, else ``fonts`` under the MeshTerm config directory).
reads (``$MESHTERM_EMULATOR_FONTS``, else ``fonts`` under the MeshTerm config directory).
Run it once on a machine that will run the host or its desktop simulator:
@@ -28,7 +28,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from meshterm.host.font import BOLD_BDF, REGULAR_BDF, font_dir # noqa: E402
from meshterm.emulator.font import BOLD_BDF, REGULAR_BDF, font_dir # noqa: E402
URL = (
"https://sourceforge.net/projects/terminus-font/files/terminus-font-4.49/"
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
"""The Cardputer's console host: its terminal, keys, font, pixels, and a whole run."""
"""The Cardputer's emulator: its terminal, keys, font, pixels, and a whole run."""
from __future__ import annotations
@@ -9,13 +9,13 @@ import time
from prompt_toolkit.input.vt100_parser import Vt100Parser
from prompt_toolkit.keys import Keys
from meshterm.host.device import KeyState
from meshterm.host.font import CELL_H, MARKS, MISSING, build_font, load_bdf
from meshterm.host.keys import Key, encode
from meshterm.host.raster import PANEL_H, PANEL_W, Raster, rgb565
from meshterm.host.run import host_output, run
from meshterm.host.sim import key_from_tk
from meshterm.host.vt import BOLD, REVERSE, UNDERLINE, Terminal
from meshterm.emulator.font import CELL_H, MARKS, MISSING, build_font, load_bdf
from meshterm.emulator.framebuffer import KeyState
from meshterm.emulator.keys import Key, encode
from meshterm.emulator.raster import PANEL_H, PANEL_W, Raster, rgb565
from meshterm.emulator.run import panel_output, run
from meshterm.emulator.vt import BOLD, REVERSE, UNDERLINE, Terminal
from meshterm.emulator.window import key_from_tk
from meshterm.ui.tui.fkeys import CARDPUTER_ZERO_DECK
_BDF = """STARTFONT 2.1
@@ -112,7 +112,7 @@ def test_prompt_toolkit_draws_into_it() -> None:
"""The output the host hands prompt_toolkit really does land in the grid."""
term = Terminal(20, 2)
frames: list[int] = []
output = host_output(term, threading.Lock(), lambda: frames.append(1))
output = panel_output(term, threading.Lock(), lambda: frames.append(1))
output.cursor_goto(2, 4) # 1-based, as a terminal counts
output.write("hello")
output.flush()
@@ -143,7 +143,7 @@ def test_modified_navigation_and_control_letters() -> None:
def test_tk_events_become_keys() -> None:
"""The simulator reads Shift, Ctrl and text off Tk's events."""
"""The window reads Shift, Ctrl and text off Tk's events."""
assert key_from_tk("F4", "", 0x0001) == Key(name="f4", shift=True)
assert key_from_tk("q", "\x11", 0x0004) == Key(text="q", ctrl=True)
assert key_from_tk("a", "a", 0) == Key(text="a")
@@ -269,7 +269,7 @@ def test_meshterm_runs_inside_the_host(monkeypatch) -> None:
def test_the_cardputer_inventory_is_what_the_host_draws() -> None:
"""``fontset.CARDPUTER_ZERO_CODEPOINTS`` holds every mark, and the installed font exactly."""
from meshterm.host.font import ALIASES, BRAILLE, font_dir, load_bdf
from meshterm.emulator.font import ALIASES, BRAILLE, font_dir, load_bdf
from meshterm.ui.fontset import CARDPUTER_ZERO_CODEPOINTS
ours = set(MARKS) | set(ALIASES) | set(BRAILLE)
+1 -1
View File
@@ -1637,7 +1637,7 @@ def test_gallery_screen_fits_its_platform(
# console font. Together these are the parity gate that catches a stray emoji or hex
# colour the moment a screen grows one, instead of as tofu found on-device.
# A handheld may emit nothing outside its own font (Platform.font): the PicoCalc's
# 512-glyph console font, or what the Cardputer's console host draws. And a console
# 512-glyph console font, or what the Cardputer's emulator draws. And a console
# with 16 slots (the PicoCalc's) may carry no truecolor or 256-colour SGR either.
# Together these are the parity gate that catches a stray emoji or hex colour the
# moment a screen grows one, instead of as tofu found on-device.