GitHub

TerminalService

API reference for TerminalService.

Effect's Terminal; the constructor is Terminal.make.

Attributes

AttributeTypeDescription
columnsEffect[int]

The terminal's width in character cells. Never fails.

rowsEffect[int]

The terminal's height in character cells. Never fails.

sizeEffect[Dequeue[Size, Done], Never, Scope]

A queue holding the current Size, then each resize until the scope closes, keeping only the latest. Never fails.

read_inputEffect[Dequeue[UserInput, Done], Never, Scope]

A queue of key presses from standard input for as long as the scope is open; it ends when input ends or the user quits. Never fails.

read_lineEffect[str, QuitError]

Reads one line from standard input, without its line break. Fails with QuitError when input ends first.

Functions

__init__

__init__(*, columns, rows, size, read_input, read_line, display) -> None
ParameterTypeDescription
columnsEffect[int]
rowsEffect[int]
sizeEffect[Dequeue[Size, Done], Never, Scope]
read_inputEffect[Dequeue[UserInput, Done], Never, Scope]
read_lineEffect[str, QuitError]
displayCallable[[str], Effect[None, PlatformError]]
def __init__(
    self,
    *,
    columns: Effect[int],
    rows: Effect[int],
    size: Effect[Dequeue[Size, Done], Never, Scope],
    read_input: Effect[Dequeue[UserInput, Done], Never, Scope],
    read_line: Effect[str, QuitError],
    display: Callable[[str], Effect[None, PlatformError]],
) -> None:
    for name, value in (
        ("columns", columns),
        ("rows", rows),
        ("size", size),
        ("read_input", read_input),
        ("read_line", read_line),
    ):
        require_effect(value, name)
    self._columns = columns
    self._rows = rows
    self._size = size
    self._read_input = read_input
    self._read_line = read_line
    self._display = display

display

display(text) -> Effect[None, PlatformError]

Writes text to standard output. Fails with a PlatformError when the write does.

ParameterTypeDescription
textstr

Returns Effect[None, PlatformError]

def display(self, text: str) -> Effect[None, PlatformError]:
    """Writes ``text`` to standard output. Fails with a
    ``PlatformError`` when the write does."""
    return self._display(text)