testing library
Testing utilities for terminice_core.
Provides mock terminal implementations for unit testing prompts and terminal-based code without a real terminal attached.
import 'package:terminice_core/testing.dart';
final mock = MockTerminal();
mock.mockInput.queueKey(KeyEventType.enter);
TerminalContext.current = mock;
Classes
- CardRender
- ColumnConfig
- Configuration for a table column.
- CursorState
- Cursor state for text input prompts.
- DartTerminal
- Default Terminal implementation using dart:io stdin/stdout.
- DartTerminalInput
- Default TerminalInput implementation using dart:io stdin.
- DartTerminalOutput
- Default TerminalOutput implementation using dart:io stdout.
- DiscreteValuePrompt
- DiscreteValuePrompt – for discrete value selection (ratings, stars).
- DisplayFeatures
- Display feature flags controlling presentation behavior.
-
DynamicListPrompt<
T> - DynamicListPrompt – composable system for lists with dynamic items.
- EndBehavior
- Configuration for end-of-prompt behavior.
- ErrorTerminal
- A terminal that always throws to test error handling.
- ErrorTerminalInput
- ErrorTerminalOutput
- Manages focus navigation (with optional per-item error tracking) for views where every item is already visible.
- FormFieldConfig
- Configuration for a single text field inside a FormPrompt.
- FormPrompt
- A multi-field text input prompt rendered inside a single FrameView.
- FormResult
- The confirmed result of a FormPrompt, containing all field values.
- FrameContext
- Context passed to the content callback during frame rendering.
- FramedLayout
- FramedLayout – pure string generator for framed terminal output.
- FrameRenderer
- Helpers to render titles and horizontal border lines consistently.
- FrameView
- FrameView – Composable frame rendering for terminal views.
- GridLayout
- Layout information for a grid.
- Manages 2D grid navigation with predictable wrapping semantics.
-
GridRow<
T> - A row of items in a grid.
- HintFormat
- Centralized formatting helpers for keyboard hint blocks.
- InlineStyle
- InlineStyle – theme-aware inline text styling utilities.
- KeyBinding
- A single key binding that maps key events to actions.
- KeyBindings
- A composable collection of key bindings.
- KeyEvent
- Normalized key event captured from terminal input.
- KeyEventReader
- Synchronous key event reader for raw terminal input.
- LineBuilder
- LineBuilder – Centralized line-level styling utilities for terminal views.
- Manages list navigation state (selection + viewport scrolling) for terminal and TUI experiences.
- ListViewport
- Viewport information for list rendering.
-
ListWindow<
T> - A window of visible items from a list.
- MockTerminal
- A mock terminal implementation for testing.
- MockTerminalInput
- Mock input that allows queuing bytes and lines for testing.
- MockTerminalOutput
- Mock output that captures all written content for assertions.
- PromptRunner
- A centralized runner for interactive terminal prompts.
-
PromptState<
T> - Mutable state container for prompt values.
- PromptTheme
- Rich styling bundle composing colors, glyphs, and display features.
- RangeResult
- RangeValuePrompt
- RangeValuePrompt – for selecting a range with two handles.
-
RankedItem<
T> - A ranked item with score and highlight spans.
-
RankedListPrompt<
T> - RankedListPrompt – composable system for searchable lists with custom ranking.
- RankResult
- Result of ranking an item.
- RenderOutput
- A line-tracking output buffer that only clears what it wrote.
-
SearchableListPrompt<
T> - SearchableListPrompt – composable system for searchable/filterable list prompts.
-
SelectableGridPrompt<
T> - SelectableGridPrompt – composable system for grid-based selection prompts.
-
SelectableListPrompt<
T> - SelectableListPrompt – composable system for list-based selection prompts.
-
SelectableListPromptBuilder<
T> - Builder for creating customized SelectableListPrompt instances.
- SelectionController
- Manages selection state for list and grid based views.
-
SimplePrompt<
T> -
SimplePrompt<T>– A lightweight, composable prompt wrapper. - SimplePrompts
- Factory methods for common SimplePrompt patterns.
- SpyTerminal
- A terminal that tracks method calls for verification.
- SpyTerminalInput
- SpyTerminalOutput
- SyncPrompts
- Factory methods for common sync prompt patterns.
- SyntaxHighlighter
- SyntaxHighlighter – theme-aware syntax highlighting utilities.
- TableRenderer
- Centralized table rendering utility.
- Terminal
- Abstract terminal interface for I/O operations.
- TerminalColors
- Color palette for terminal output using ANSI escape sequences.
- TerminalContext
- Global context for accessing the current Terminal instance.
- TerminalControl
- Terminal utilities used across components and prompts to manage raw mode and input.
- TerminalGlyphs
- Glyph set for structural terminal elements.
- TerminalInfo
- Provides safe, cached access to terminal dimensions with sensible defaults.
- TerminalInput
- Abstract input interface for terminal operations.
- TerminalModeState
- Captures original terminal state and restores it on restore.
- TerminalOutput
- Abstract output interface for terminal operations.
- TerminalSession
- Manages terminal session state (cursor visibility, raw mode).
- TerminalSize
- TextInputBuffer
- Manages text input state with cursor positioning.
- TextInputState
- Extended state for text input prompts.
- TextPromptSync
-
TextPromptSync– Sync text input prompt with validation. - TextWithBlockCursor
- ValuePrompt
- ValuePrompt – composable system for continuous value selection.
Enums
- BadgeTone
- Semantic badge tones shared by style-aware components.
- ColumnAlign
- Alignment options for table columns.
- DynamicAction
- Actions that can be returned from dynamic list handlers.
- HintStyle
- Hint display style options for keyboard bindings.
- KeyActionResult
- Result of a key action handler.
- KeyEventType
- Normalized terminal key event types.
- PromptResult
- Result from a prompt indicating whether it was confirmed or cancelled.
- SpinnerFrames
- Spinner frame styles.
- StatTone
- Tone for stat/styled items.
Mixins
- Helper for path-like navigation.
- Helper for tree-like hierarchical navigation.
Extensions
- FrameViewDisplayExtensions on FrameView
- Extension methods for display-only (non-interactive) frame rendering.
- HintKeybindingsExtensions on KeyBindings
-
Convenience extensions so
KeyBindingscan emit polished hint strings. - PromptRunnerFrameExtension on PromptRunner
- Extension to simplify FrameView usage with PromptRunner.
-
SelectableGridPromptCards
on SelectableGridPrompt<
T> - Extension for card-style grid rendering (ChoiceMap pattern).
-
SelectableGridPromptTags
on SelectableGridPrompt<
T> - Extension for tag-style grid rendering.
-
SelectableListPromptExt
on SelectableListPrompt<
T> - Extension for adding select-all functionality.
- SelectionControllerExt on SelectionController
- Extension to integrate SelectionController with ListNavigator.
-
SimplePromptBuilder
on SimplePrompt<
T> - Extension for creating SimplePrompt with builder pattern.
- SimpleTextInput on TextInputBuffer
- Extension for simpler text-only usage (no cursor tracking).
- TextInputBindingsExtensions on TextInputBuffer
- ValuePromptRendering on FrameContext
- Helper extension for rendering value prompts.
Constants
-
arcsFrames
→ const List<
String> - Unicode arc-style spinner frames (quarter-circle characters).
-
barsFrames
→ const List<
String> - Unicode bar-style spinner frames (block elements).
-
dotsFrames
→ const List<
String> - Unicode dot-style spinner frames (braille characters).
Functions
-
clampInt(
int value, int min, int max) → int -
Clamps
valuebetweenminandmax(inclusive). -
columnWidth(
Iterable< String> values, {int min = 0, int max = 999}) → int - Computes optimal column width from content lengths, clamped to bounds.
-
columnWidthVisible(
Iterable< String> values, {int min = 0, int max = 999}) → int - Computes optimal column width from styled content (ANSI-aware).
-
fuzzyMatch(
String text, String pattern) → RankResult? - Standard fuzzy matcher with scoring.
-
highlightSpans(
String text, List< int> indices, PromptTheme theme) → String - Highlights matched spans in text using theme colors.
-
highlightSubstring(
String text, String query, PromptTheme theme, {bool enabled = true}) → String -
Highlights the first case-insensitive occurrence of
queryintextusing the theme's highlight color, preserving the rest of the string. Ifenabledis false orqueryis empty/missing, returnstextunchanged. -
maxOf(
Iterable< int> values) → int - Finds the maximum value in an iterable of integers.
-
minOf(
Iterable< int> values) → int - Finds the minimum value in an iterable of integers.
-
padLeft(
String text, int width) → String -
Pads
texttowidthwith leading spaces. -
padRight(
String text, int width) → String -
Pads
texttowidthwith trailing spaces. -
padVisibleCenter(
String text, int width) → String -
Centers styled
textwithinwidthbased on visible character length. -
padVisibleLeft(
String text, int width) → String -
Pads styled
texttowidthbased on visible character length, left-aligned. -
padVisibleRight(
String text, int width) → String -
Pads styled
texttowidthbased on visible character length. -
spinnerFramesList(
SpinnerFrames style) → List< String> - Returns the frame list for the given SpinnerFrames style.
-
standardMatch(
String text, String pattern, bool useFuzzy) → RankResult? - Combines fuzzy and substring matching based on mode.
-
stripAnsi(
String input) → String -
Removes ANSI escape codes from
input. -
substringMatch(
String text, String pattern) → RankResult? - Standard substring matcher with scoring.
-
toneColor(
StatTone tone, PromptTheme theme) → String - Returns the ANSI color for a StatTone.
-
truncate(
String text, int width) → String -
Truncates
texttowidthcharacters, adding an ellipsis if clipped. -
truncatePad(
String text, int width) → String -
Truncates
texttowidthand pads to fill remaining space. -
visibleLength(
String text) → int -
Returns the visible (printable) character count of
textafter stripping ANSI.