@@ -8,9 +8,6 @@ import 'package:terminal_color_parser/terminal_color_parser.dart';
8
8
9
9
final coloredText = ColorParser('Hello, \x1B[32mworld\x1B[0m!').parse();
10
10
11
- print(coloredText);
12
- // ==> ColorToken("Hello, ", 0:0, , ()), ColorToken("world", 32:0, , ()), ColorToken("!", 0:0, , ())]
13
-
14
11
var i = 0;
15
12
for (final token in coloredText) {
16
13
print('Token #$i: ${token.formatted}');
@@ -29,22 +26,22 @@ You can also re-format the ANSI codes by using the `formatted` property on each
29
26
30
27
``` dart
31
28
final tokens = [
32
- ColorToken(text: 'Hello, ', fgColor: 0, bgColor: 0 ),
29
+ ColorToken(text: 'Hello, '),
33
30
ColorToken(
34
31
text: 'world',
35
- fgColor: 32,
36
- bgColor: 0 ,
32
+ fgColor: ANSIColor.fg(32), // Can also use RGBColor.fg(r, g, b)
33
+ bgColor: Color.none ,
37
34
styles: {StyleByte.underline},
38
35
),
39
- ColorToken(text: '!', fgColor: 0, bgColor: 0 ),
36
+ ColorToken(text: '!'),
40
37
];
41
38
42
39
var i = 0;
43
40
for (final token in coloredText) {
44
41
print('Token #$i: ${token.formatted}');
45
42
print(' - Text: ${token.text}');
46
- print(' - Foreground: ${token.fgColor}');
47
- print(' - Background: ${token.bgColor}');
43
+ print(' - Foreground: ${token.fgColor.formatted }');
44
+ print(' - Background: ${token.bgColor.formatted }');
48
45
print(' - Bold: ${token.bold}');
49
46
print(' - Italic: ${token.italic}');
50
47
print(' - Underline: ${token.underline}');
0 commit comments