Terminal API

The wijjit.terminal package abstracts ANSI escapes, screen buffers, keyboard/mouse input, and cursor control. Use these classes when building custom renderers or writing low-level tests.

ANSI helpers

wijjit.terminal.ansi.ANSIColor

ANSI color codes for text and background.

wijjit.terminal.ansi.ANSIStyle

ANSI text styling codes.

wijjit.terminal.ansi.ANSICursor

ANSI cursor control codes.

wijjit.terminal.ansi.ANSIScreen

ANSI screen control codes.

wijjit.terminal.ansi.visible_length

Get the visible display width of text (excluding ANSI codes).

wijjit.terminal.ansi.wrap_text

Wrap a single line of text into multiple segments based on width.

wijjit.terminal.ansi.clip_to_width

Clip text to specified width, preserving ANSI codes.

wijjit.terminal.ansi.strip_ansi

Remove all ANSI escape sequences from text.

wijjit.terminal.ansi.colorize

Apply ANSI colors and styles to text.

Input & mouse

wijjit.terminal.input.KeyType

Type of key press.

wijjit.terminal.input.Key

Represents a keyboard key press.

wijjit.terminal.input.Keys

Common keyboard key definitions.

wijjit.terminal.input.InputHandler

Handles reading and parsing keyboard and mouse input using prompt_toolkit.

wijjit.terminal.mouse.MouseEvent

Represents a mouse event.

wijjit.terminal.mouse.MouseEventType

Types of mouse events.

wijjit.terminal.mouse.MouseButton

Mouse button identifiers.

wijjit.terminal.mouse.MouseTrackingMode

Mouse tracking modes for ANSI terminals.

wijjit.terminal.mouse.MouseEventParser

Parser for ANSI mouse event sequences.

Screen & buffers

wijjit.terminal.screen.ScreenManager

Manages terminal screen state and alternate buffer.

wijjit.terminal.screen.alternate_screen

Context manager for alternate screen buffer.

wijjit.terminal.cell.Cell

A single terminal cell with character and styling attributes.

wijjit.terminal.cell.CellPool

Pool of pre-allocated common Cell objects for performance.

wijjit.terminal.screen_buffer.ScreenBuffer

2D buffer of terminal cells with dirty region tracking.

wijjit.terminal.screen_buffer.DiffRenderer

Efficiently renders changes between two buffers.