mansion 0.1.0 mansion: ^0.1.0 copied to clipboard
A stately library for crafting and deciphering ANSI escape codes.
Mansion #
A stately library for crafting and deciphering ANSI escape codes.
Styling text is ~1-line with lots of possibilities:
print('Hello World'.style(Style.foreground(Color.red), Style.bold));
When you're ready, graduate to a full-featured package for more control:
stdout.writeAnsiAll([
// Sets the cursor position to the top-left corner.
CursorPosition.reset,
// Clear the screen.
Clear.all,
// Set a bunch of styles.
SetStyles(
Style.bold,
Style.underline,
Style.italic,
Style.foreground(Color.red),
Style.background(Color.green),
),
// Print some text.
Print('Hello, World!'),
// Reset all styles.
SetStyles.reset,
// Move the cursor to the next line.
AsciiControl.lineFeed,
]);
Includes a full-featured ANSI escape decoder for writing terminal emulators!
Features #
- Cross-platform support for most popular ANSI escape codes.
- Fully tested and documented with examples and explanations.
- Walkthroughs for common use-cases and best practices.
- Intuitive API using the latest Dart features.
- Practically zero dependencies (only
meta
for annotations).
Importantly, mansion
is not a general purpose terminal library; it does not
provide terminal emulation, any real input handling other than event code
parsing, anything to do with FFI or native code, or any other terminal-related
functionality.
Build on top of mansion
to create your own terminal libraries, or use it to
style text in your command-line applications.
Contributing #
To run the tests, run:
dart test
To check code coverage locally, run:
dart tool/coverage.dart
To preview dartdoc
output locally, run:
dart tool/dartdoc.dart