terminal library Terminal
Unified terminal module for artisanal.
This library provides a single source of truth for terminal operations used throughout the package, including both static components and the TUI runtime.
Quick Start
import 'package:artisanal/terminal.dart';
// Create a terminal
final terminal = StdioTerminal();
// Use terminal operations
terminal.hideCursor();
terminal.write('Hello, ');
terminal.writeln('World!');
terminal.showCursor();
// Use ANSI codes directly
import 'dart:io';
stdout.write(Ansi.bold);
stdout.write('Bold text');
stdout.write(Ansi.reset);
// Check key input
if (Keys.isPrintable(byte)) { ... }
Terminal Abstraction
Artisanal provides a unified Terminal interface that abstracts away the differences between standard I/O, string buffers (for testing), and specialized terminal emulators.
- StdioTerminal: The default implementation for real terminal apps.
- StringTerminal: Useful for unit testing terminal output.
- TuiTerminal: Extended interface for interactive TUI applications.
Raw Mode and Input
Interactive applications often require "raw mode" to receive input character-by-character without waiting for a newline, and to disable local echo.
Use RawModeGuard or Terminal.enableRawMode to manage this state safely. Always ensure raw mode is disabled before the program exits to avoid leaving the user's terminal in a broken state.
ANSI and Escape Sequences
Artisanal includes a comprehensive Ansi utility class for generating standard ANSI escape sequences for colors, styles, cursor movement, and screen control.
For more advanced rendering, see the Ultraviolet subsystem.
Artisanal provides a unified Terminal interface that abstracts away the differences between standard I/O, string buffers (for testing), and specialized terminal emulators.
- StdioTerminal: The default implementation for real terminal apps.
- StringTerminal: Useful for unit testing terminal output.
- TuiTerminal: Extended interface for interactive TUI applications.
Interactive applications often require "raw mode" to receive input character-by-character without waiting for a newline, and to disable local echo.
Use RawModeGuard or Terminal.enableRawMode to manage this state safely. Always ensure raw mode is disabled before the program exits to avoid leaving the user's terminal in a broken state.
Artisanal includes a comprehensive Ansi utility class for generating standard ANSI escape sequences for colors, styles, cursor movement, and screen control.
For more advanced rendering, see the Ultraviolet subsystem.
Classes
- Ansi Terminal
- Unified ANSI escape sequence constants and utilities.
- ITerm2Image
- Utilities for the iTerm2 Image Protocol.
- Key
- Represents a parsed keyboard input event.
- Keys
- Key constants and utilities for keyboard input handling.
- KittyImage
- Utilities for the Kitty Graphics Protocol.
- RawModeGuard
- Guard object returned by Terminal.enableRawMode.
- Shared broadcast input stream wrapper.
- SixelImage
- Utilities for Sixel Graphics.
- SplitTerminal
- A terminal that splits "control/input" from "display/output".
- StdioTerminal
- Standard terminal implementation using dart:io.
- StringTerminal
- A terminal that captures output to a string buffer (for testing).
- Terminal Terminal
- Abstract terminal interface for all terminal operations.
- TtyTerminal
-
POSIX
/dev/ttyterminal implementation.
Enums
- KeyType
- Types of keyboard input events.
Properties
Functions
- Shuts down the shared stdin stream so the process can exit cleanly.