Skip to main content

Module term

Module term 

Source
Expand description

A terminal, hand-rolled on libc.

ratatui is the obvious answer, and adding it to this workspace resolves 35 crates that are not already here β€” a 30% increase on a tree whose size (117 crates, 5.63 MiB) is a stated property of the product. What it buys over this file is a constraint-solving layout engine and a damage-tracked cell buffer; the TUI here has fixed panes and redraws one screenful per keystroke. So: termios for raw mode, TIOCGWINSZ for the size, poll(2) for input, three sigactions to survive a resize and a kill, ANSI for the rest. libc is already in the tree for statfs.

Unix only, which is the same bet mmap, SIGTERM and the filesystem guard already make.

StructsΒ§

Row
One line of the frame, built left to right with its visible width tracked separately from its bytes.
Term

EnumsΒ§

Key
Parsed πŸ”’

ConstantsΒ§

BLUE
BOLD
CYAN
DIM
GREEN
MAGENTA
RED
RESET
REV
YELLOW

StaticsΒ§

ORIG πŸ”’
The terminal settings as they were before Term::enter.

FunctionsΒ§

bail πŸ”’ ⚠
Give the terminal back, then die.
csi πŸ”’
ok_or_errno πŸ”’
The termios calls’ contract: 0, or -1 and the reason is in errno.
on_signal πŸ”’
Install h for sig, without SA_RESTART.
parse πŸ”’
One key off the front of b, or Parsed::Need if what is there could still grow into a longer sequence.
poll_in πŸ”’
restore πŸ”’
Put the terminal back. Idempotent, because Drop, the panic hook and a fatal signal can all reach it and a double panic would otherwise run it twice.
take_one πŸ”’
winch πŸ”’ ⚠
A resize. Nothing to do in the handler β€” the delivery itself is the message, and it arrives as an EINTR in poll_in.