Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frencojobs/tint
Terminal string styling library for Dart.
https://github.com/frencojobs/tint
dart terminal-style
Last synced: about 14 hours ago
JSON representation
Terminal string styling library for Dart.
- Host: GitHub
- URL: https://github.com/frencojobs/tint
- Owner: frencojobs
- License: mit
- Created: 2020-12-18T13:45:40.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-04T20:10:20.000Z (almost 2 years ago)
- Last Synced: 2024-06-19T03:13:51.821Z (5 months ago)
- Topics: dart, terminal-style
- Language: Dart
- Homepage: https://pub.dev/packages/tint
- Size: 34.2 KB
- Stars: 27
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Tint
Tint is a library for terminal string styling extended upon Dart's `String` type.
## Overview
```dart
// tint.dart
import 'package:tint/tint.dart';void main() {
print('underlined blue text on white background'
.underline()
.blue()
.onWhite());
}
```The snippet will produce an underlined blue text on a white background once you run it inside a terminal.
The example at `example/main.dart` file contains examples for all APIs. Try running it and you'll get something this.
## Installation
Install the latest version of tint as a dependency as shown in [pub.dev](https://pub.dev/packages/tint).
## API Documentation
For reference, all of the available APIs will be used as an example in the `example/main.dart` file.
**Foreground Colors**
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `brightBlack` or `gray` or `grey`
- `brightRed`
- `brightGreen`
- `brightYellow`
- `brightBlue`
- `brightMagenta`
- `brightCyan`
- `brightWhite`
**Background Colors**
- `onBlack`
- `onRed`
- `onGreen`
- `onYellow`
- `onBlue`
- `onMagenta`
- `onCyan`
- `onWhite`
- `onBrightBlack` or `onGray` or `onGrey`
- `onBrightRed`
- `onBrightGreen`
- `onBrightYellow`
- `onBrightBlue`
- `onBrightMagenta`
- `onBrightCyan`
- `onBrightWhite`
**Attributes**
- `bold`
- `dim`
- `italic`
- `underline`
- `blink`
- `inverse`
- `strikethrough`
**Dynamic Colors**
- `rgb({int r, int g, int b})`
- `onRgb({int r, int g, int b})`
**Utilities**
- `reset` (reset the color using ANSI code)
- `strip` (remove all ANSI codes)
## Alternatives
Tint is an alternative to,
- [ansi_styles](https://pub.dev/packages/ansi_styles)
- [ansicolor](https://pub.dev/packages/ansicolor)
## Acknowledgement
Node's [chalk](https://github.com/chalk/chalk) is the library that inspired tint the most but the naming of the APIs such as `onMagenta` instead of `bgMagenta` and certain aspects of the library are mostly influenced by the [console](https://github.com/mitsuhiko/console) crate from Rust. The [ansicolor](https://pub.dev/packages/ansicolor) and [ansi_styles](https://pub.dev/packages/ansi_styles) packages also provide the same functionality but with a different delivery for the usage. But I personally find extension methods syntactically more fun to use.