Skip to content

Changes for landing https://github.com/dart-lang/sdk/issues/32161 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions lib/ansicolor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,29 @@ class AnsiPen {
/// attributes.
String write(String msg) => "${this}$msg$up";

black({bool bg: false, bool bold: false}) => _std(0, bold, bg);
red({bool bg: false, bool bold: false}) => _std(1, bold, bg);
green({bool bg: false, bool bold: false}) => _std(2, bold, bg);
yellow({bool bg: false, bool bold: false}) => _std(3, bold, bg);
blue({bool bg: false, bool bold: false}) => _std(4, bold, bg);
magenta({bool bg: false, bool bold: false}) => _std(5, bold, bg);
cyan({bool bg: false, bool bold: false}) => _std(6, bold, bg);
white({bool bg: false, bool bold: false}) => _std(7, bold, bg);
void black({bool bg: false, bool bold: false}) => _std(0, bold, bg);
void red({bool bg: false, bool bold: false}) => _std(1, bold, bg);
void green({bool bg: false, bool bold: false}) => _std(2, bold, bg);
void yellow({bool bg: false, bool bold: false}) => _std(3, bold, bg);
void blue({bool bg: false, bool bold: false}) => _std(4, bold, bg);
void magenta({bool bg: false, bool bold: false}) => _std(5, bold, bg);
void cyan({bool bg: false, bool bold: false}) => _std(6, bold, bg);
void white({bool bg: false, bool bold: false}) => _std(7, bold, bg);

/// Sets the pen color to the rgb value between 0.0..1.0.
rgb({r: 1.0, g: 1.0, b: 1.0, bool bg: false}) => xterm(
void rgb({r: 1.0, g: 1.0, b: 1.0, bool bg: false}) => xterm(
(r.clamp(0.0, 1.0) * 5).toInt() * 36 +
(g.clamp(0.0, 1.0) * 5).toInt() * 6 +
(b.clamp(0.0, 1.0) * 5).toInt() +
16,
bg: bg);

/// Sets the pen color to a grey scale value between 0.0 and 1.0.
gray({level: 1.0, bool bg: false}) =>
void gray({level: 1.0, bool bg: false}) =>
xterm(232 + (level.clamp(0.0, 1.0) * 23).round(), bg: bg);

_std(int color, bool bold, bool bg) => xterm(color + (bold ? 8 : 0), bg: bg);
void _std(int color, bool bold, bool bg) =>
xterm(color + (bold ? 8 : 0), bg: bg);

/// Directly index the xterm 256 color palette.
void xterm(int color, {bool bg: false}) {
Expand Down