Skip to content

Commit 3617ad3

Browse files
committed
feat: initial commit
0 parents  commit 3617ad3

19 files changed

+781
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[*]
2+
tab_width = 2
3+
indent_size = 2
4+
indent_style = space
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
8+
[*.md]
9+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
templates/
2+
scaffolds/

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: chenasraf
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: casraf
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom:
13+
[
14+
'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TSH3C3ABGQM22&currency_code=ILS&source=url'
15+
]

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/
4+
5+
# Avoid committing pubspec.lock for library packages; see
6+
# https://dart.dev/guides/libraries/private-files#pubspeclock.
7+
pubspec.lock
8+
9+
# secrets
10+
.env
11+
12+
# docs
13+
doc/

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
templates/
2+
scaffolds/

.prettierrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"printWidth": 100,
3+
"semi": false,
4+
"singleQuote": true,
5+
"trailingComma": "all",
6+
"overrides": [
7+
{
8+
"files": "*.md",
9+
"options": {
10+
"printWidth": 100,
11+
"proseWrap": "always"
12+
}
13+
}
14+
]
15+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.5.0
2+
3+
- Initial version.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright © 2023 Chen Asraf
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Terminal Color Parser
2+
3+
This package is an ANSI/xterm256 color parser. You can get the list of colored segments by creating
4+
a `ColorParser` instance and calling `parse()` method.
5+
6+
```dart
7+
import 'package:terminal_color_parser/terminal_color_parser.dart';
8+
9+
final coloredText = ColorParser('Hello, \x1B[32mworld\x1B[0m!').parse();
10+
11+
print(coloredText);
12+
// ==> ColoredText("Hello, ", 0:0, , ()), ColoredText("world", 32:0, , ()), ColoredText("!", 0:0, , ())]
13+
14+
var i = 0;
15+
for (final token in coloredText) {
16+
print('Token #$i: ${token.formatted}');
17+
print(' - Text: ${token.text}');
18+
print(' - Foreground: ${token.fgColor}');
19+
print(' - Background: ${token.bgColor}');
20+
print(' - Bold: ${token.bold}');
21+
print(' - Italic: ${token.italic}');
22+
print(' - Underline: ${token.underline}');
23+
print(' - Styles: ${token.styles}');
24+
i++;
25+
}
26+
```
27+
28+
You can also re-format the ANSI codes by using the `formatted` property on each token.
29+
30+
```dart
31+
final tokens = [
32+
ColorToken(text: 'Hello, ', fgColor: 0, bgColor: 0),
33+
ColorToken(
34+
text: 'world',
35+
fgColor: 32,
36+
bgColor: 0,
37+
styles: {StyleByte.underline},
38+
),
39+
ColorToken(text: '!', fgColor: 0, bgColor: 0),
40+
];
41+
42+
var i = 0;
43+
for (final token in coloredText) {
44+
print('Token #$i: ${token.formatted}');
45+
print(' - Text: ${token.text}');
46+
print(' - Foreground: ${token.fgColor}');
47+
print(' - Background: ${token.bgColor}');
48+
print(' - Bold: ${token.bold}');
49+
print(' - Italic: ${token.italic}');
50+
print(' - Underline: ${token.underline}');
51+
print(' - Styles: ${token.styles}');
52+
i++;
53+
}
54+
```
55+
56+
## Contributing
57+
58+
I am developing this package on my free time, so any support, whether code, issues, or just stars is
59+
very helpful to sustaining its life. If you are feeling incredibly generous and would like to donate
60+
just a small amount to help sustain this project, I would be very very thankful!
61+
62+
<a href='https://ko-fi.com/casraf' target='_blank'>
63+
<img height='36' style='border:0px;height:36px;'
64+
src='https://cdn.ko-fi.com/cdn/kofi1.png?v=3'
65+
alt='Buy Me a Coffee at ko-fi.com' />
66+
</a>
67+
68+
I welcome any issues or pull requests on GitHub. If you find a bug, or would like a new feature,
69+
don't hesitate to open an appropriate issue and I will do my best to reply promptly.

analysis_options.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options

0 commit comments

Comments
 (0)