This repository has been archived by the owner on Feb 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
676 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
import 'package:terminal_decorate/terminal_decorate.dart'; | ||
|
||
void main() => colorExample(); | ||
|
||
void colorExample() { | ||
for (final line in singleForegroundLines) print(line); | ||
for (final line in singleBackgroundLines) print(line); | ||
print(complexForegroundLine()); | ||
print(complexBackgroundLine()); | ||
} | ||
|
||
final singleForegroundLines = [ | ||
singleForegroundLine( | ||
code: Escape.foregroundBlack, | ||
content: 'black'.black, | ||
comment: 'black, sometimes dark gray', | ||
), | ||
singleForegroundLine(code: Escape.foregroundRed, content: 'red'.red), | ||
singleForegroundLine(code: Escape.foregroundYellow, content: 'yellow'.yellow), | ||
singleForegroundLine(code: Escape.foregroundGreen, content: 'green'.green), | ||
singleForegroundLine(code: Escape.foregroundCyan, content: 'cyan'.cyan), | ||
singleForegroundLine(code: Escape.foregroundBlue, content: 'blue'.blue), | ||
singleForegroundLine( | ||
code: Escape.foregroundMagenta, | ||
content: 'magenta'.magenta, | ||
), | ||
singleForegroundLine( | ||
code: Escape.foregroundWhite, | ||
content: 'white'.white, | ||
comment: 'white, sometimes light gray', | ||
), | ||
singleForegroundLine( | ||
code: Escape.foregroundHiBlack, | ||
content: 'hi black'.hiBlack, | ||
comment: 'hi black', | ||
), | ||
singleForegroundLine(code: Escape.foregroundHiRed, content: 'hi red'.hiRed), | ||
singleForegroundLine( | ||
code: Escape.foregroundHiYellow, | ||
content: 'hi yellow'.hiYellow, | ||
), | ||
singleForegroundLine( | ||
code: Escape.foregroundHiGreen, | ||
content: 'hi green'.hiGreen, | ||
), | ||
singleForegroundLine( | ||
code: Escape.foregroundHiCyan, | ||
content: 'hi cyan'.hiCyan, | ||
), | ||
singleForegroundLine( | ||
code: Escape.foregroundHiBlue, | ||
content: 'hi blue'.hiBlue, | ||
), | ||
singleForegroundLine( | ||
code: Escape.foregroundHiMagenta, | ||
content: 'hi magenta'.hiMagenta, | ||
), | ||
singleForegroundLine( | ||
code: Escape.foregroundHiWhite, | ||
content: 'hi white'.hiWhite, | ||
comment: 'hi white', | ||
), | ||
]; | ||
|
||
final singleBackgroundLines = [ | ||
singleBackgroundLine( | ||
code: Escape.backgroundBlack, | ||
content: 'black'.bgBlack, | ||
comment: 'black', | ||
), | ||
singleBackgroundLine(code: Escape.backgroundRed, content: 'red'.bgRed), | ||
singleBackgroundLine( | ||
code: Escape.backgroundYellow, | ||
content: 'yellow'.bgYellow, | ||
), | ||
singleBackgroundLine(code: Escape.backgroundGreen, content: 'green'.bgGreen), | ||
singleBackgroundLine(code: Escape.backgroundCyan, content: 'cyan'.bgCyan), | ||
singleBackgroundLine(code: Escape.backgroundBlue, content: 'blue'.bgBlue), | ||
singleBackgroundLine( | ||
code: Escape.backgroundMagenta, | ||
content: 'magenta'.bgMagenta, | ||
), | ||
singleBackgroundLine( | ||
code: Escape.backgroundWhite, | ||
content: 'white'.bgWhite, | ||
comment: 'white', | ||
), | ||
singleBackgroundLine( | ||
code: Escape.backgroundHiBlack, | ||
content: 'hi black'.bgHiBlack, | ||
comment: 'hi black', | ||
), | ||
singleBackgroundLine(code: Escape.backgroundHiRed, content: 'hi red'.bgHiRed), | ||
singleBackgroundLine( | ||
code: Escape.backgroundHiYellow, | ||
content: 'hi yellow'.bgHiYellow, | ||
), | ||
singleBackgroundLine( | ||
code: Escape.backgroundHiGreen, | ||
content: 'hi green'.bgHiGreen, | ||
), | ||
singleBackgroundLine( | ||
code: Escape.backgroundHiCyan, | ||
content: 'hi cyan'.bgHiCyan, | ||
), | ||
singleBackgroundLine( | ||
code: Escape.backgroundHiBlue, | ||
content: 'hi blue'.bgHiBlue, | ||
), | ||
singleBackgroundLine( | ||
code: Escape.backgroundHiMagenta, | ||
content: 'hi magenta'.bgHiMagenta, | ||
), | ||
singleBackgroundLine( | ||
code: Escape.backgroundHiWhite, | ||
content: 'hi white'.bgHiWhite, | ||
comment: 'hi white', | ||
), | ||
]; | ||
|
||
String singleForegroundLine({ | ||
required Escape code, | ||
required String content, | ||
String? comment, | ||
}) { | ||
return [ | ||
'(${code.code}:${Escape.cancelForeground.code})', | ||
'$content color', | ||
if (comment != null) '($comment)' | ||
].join(' '); | ||
} | ||
|
||
String singleBackgroundLine({ | ||
required Escape code, | ||
required String content, | ||
String? comment, | ||
}) { | ||
return [ | ||
'(${code.code}:${Escape.cancelBackground.code})', | ||
'$content background', | ||
if (comment != null) '($comment)' | ||
].join(' '); | ||
} | ||
|
||
String complexForegroundLine() { | ||
final red = 'red'.foregroundRed; | ||
final yellow = 'yellow $red yellow'.foregroundYellow; | ||
final green = 'green $yellow green'.foregroundGreen; | ||
final cyan = 'cyan $green cyan'.foregroundCyan; | ||
final blue = 'blue $cyan blue'.foregroundBlue; | ||
final magenta = 'magenta $blue magenta'.foregroundMagenta; | ||
return 'complex $magenta line'; | ||
} | ||
|
||
String complexBackgroundLine() { | ||
final red = 'red'.backgroundRed; | ||
final yellow = 'yellow $red yellow'.backgroundYellow; | ||
final green = 'green $yellow green'.backgroundGreen; | ||
final cyan = 'cyan $green cyan'.backgroundCyan; | ||
final blue = 'blue $cyan blue'.backgroundBlue; | ||
final magenta = 'magenta $blue magenta'.backgroundMagenta; | ||
return 'complex $magenta background line'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import 'package:terminal_decorate/terminal_decorate.dart'; | ||
|
||
void main() => fontExample(); | ||
|
||
void fontExample() { | ||
for (final line in basicFontDecorations) print(line); | ||
print(mixBoldAndFaint()); | ||
print(mixBlinks()); | ||
print(mixUnderlines()); | ||
} | ||
|
||
final basicFontDecorations = [ | ||
singleFontLine( | ||
prefix: Escape.bold, | ||
suffix: Escape.cancelBoldOrFaint, | ||
content: 'bold'.bold, | ||
), | ||
singleFontLine( | ||
prefix: Escape.faint, | ||
suffix: Escape.cancelBoldOrFaint, | ||
content: 'faint/dim'.faint, | ||
), | ||
singleFontLine( | ||
prefix: Escape.italic, | ||
suffix: Escape.cancelItalic, | ||
content: 'italic'.italic, | ||
), | ||
singleFontLine( | ||
prefix: Escape.underline, | ||
suffix: Escape.cancelUnderline, | ||
content: 'underline'.underline, | ||
), | ||
singleFontLine( | ||
prefix: Escape.blink, | ||
suffix: Escape.cancelBlink, | ||
content: 'blink'.blink, | ||
comment: 'usually unsupported', | ||
), | ||
singleFontLine( | ||
prefix: Escape.rapidBlink, | ||
suffix: Escape.cancelBlink, | ||
content: 'rapid blink'.rapidBlink, | ||
comment: 'usually unsupported', | ||
), | ||
singleFontLine( | ||
prefix: Escape.negative, | ||
suffix: Escape.cancelNegative, | ||
content: 'negative'.negative, | ||
), | ||
singleFontLine( | ||
prefix: Escape.conceal, | ||
suffix: Escape.cancelConceal, | ||
content: 'conceal/hide'.conceal, | ||
comment: 'conceal/hide', | ||
), | ||
singleFontLine( | ||
prefix: Escape.crossLine, | ||
suffix: Escape.cancelCrossLine, | ||
content: 'cross line'.crossLine, | ||
), | ||
singleFontLine( | ||
prefix: Escape.doubleUnderline, | ||
suffix: Escape.cancelUnderline, | ||
content: 'double underline'.doubleUnderline, | ||
comment: 'usually unsupported', | ||
), | ||
]; | ||
|
||
String singleFontLine({ | ||
required Escape prefix, | ||
required Escape suffix, | ||
required String content, | ||
String? comment, | ||
}) { | ||
return '(${prefix.code}:${suffix.code}) $content style ' | ||
'${comment != null ? '($comment)' : ''}'; | ||
} | ||
|
||
String mixBoldAndFaint() { | ||
final bold = 'bold'.bold; | ||
final faint = 'faint $bold faint'.faint; | ||
return 'normal $faint normal'; | ||
} | ||
|
||
String mixBlinks() { | ||
final rapidBlink = 'rapid blink'.blink; | ||
final blink = 'blink $rapidBlink blink'.blink; | ||
return 'normal $blink normal (usually unsupported)'; | ||
} | ||
|
||
String mixUnderlines() { | ||
final doubleUnderline = 'double underline'.doubleUnderline; | ||
final underline = 'underline $doubleUnderline underline'.underline; | ||
return 'normal $underline normal (usually unsupported)'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import 'standard_example.dart'; | ||
import 'color_example.dart'; | ||
import 'font_example.dart'; | ||
|
||
void main() { | ||
standardExample(); | ||
fontExample(); | ||
colorExample(); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.