ansi_escape_codes 1.1.0 copy "ansi_escape_codes: ^1.1.0" to clipboard
ansi_escape_codes: ^1.1.0 copied to clipboard

Yet another package for ANSI escape codes. It differs from the others only in that it focuses on using **constants** rather than functions or methods.

ansi_escape_codes #

This is yet another package of many for ANSI escape codes. It differs from the others only in that it focuses on using constants rather than functions or methods.

const text = '${fgGreen}Lorem$fgDefault'
    ' $fgYellow${bgBrightBlack}ipsum$fgDefault$bgDefault'
    ' $fg256Open$red${fg256Close}dolor$fgDefault'
    ' $fg256Open$rgb531${fg256Close}sit$fgDefault'
    ' $fg256Open$gray9${fg256Close}amet,$fgDefault'
    ' $fg256Open$gray13${fg256Close}consectetur$fgDefault'
    ' $fg256Open$gray17${fg256Close}adipiscing$fgDefault'
    ' ${fgRgbOpen}249;105;14${fgRgbClose}elit,$fgDefault'
    ' ${bold}sed ${normalIntensity}do ${faint}eiusmod$reset'
    ' ${italic}tempor$notItalic'
    ' ${strike}incididunt$notStrike'
    ' ${underline}ut$notUnderlined'
    ' ${subscript}labore$notSuperscriptNotSubscript'
    ' et'
    ' ${superscript}dolore$notSuperscriptNotSubscript'
    ' ${blink}magna$notBlinking'
    ' ${invert}aliqua.$notInverted';

print(text);

Colors #

Standarts 16 colors #

https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit

foreground background
fgBlack bgBlack
fgRed bgRed
fgGreen bgGreen
fgYellow bgYellow
fgBlue bgBlue
fgMagenta bgMagenta
fgCyan bgCyan
fgWhite bgWhite
fgDefault bgDefault
fgBrightBlack bgBrightBlack
fgBrightRed bgBrightRed
fgBrightGreen bgBrightGreen
fgBrightYellow bgBrightYellow
fgBrightBlue bgBrightBlue
fgBrightMagenta bgBrightMagenta
fgBrightCyan bgBrightCyan
fgBrightWhite bgBrightWhite

256-color table #

https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

A template for using a color from a 256-color table:

'$fg256Open$n$fg256Close' // n: 0..255
'$bg256Open$n$bg256Close'
'$underline256Open$n$underline256Close'
Number Name
0 black
1 red
2 green
3 yellow
4 blue
5 magenta
6 cyan
7 white
8 highBlack
9 highRed
10 highGreen
11 highYellow
12 highBlue
13 highMagenta
14 highCyan
15 highWhite
16-231 rgbNNN, where N are numbers from 0 to 5
232-255 grayN, where N is a number from 0 to 23

You don't have to use a template, but take the ready-made values from the following table:

Number Name
0 (fg/bg)256Black
1 (fg/bg)256Red
2 (fg/bg)256Green
3 (fg/bg)256Yellow
4 (fg/bg)256Blue
5 (fg/bg)256Magenta
6 (fg/bg)256Cyan
7 (fg/bg)256White
8 (fg/bg)256HighBlack
9 (fg/bg)256HighRed
10 (fg/bg)256HighGreen
11 (fg/bg)256HighYellow
12 (fg/bg)256HighBlue
13 (fg/bg)256HighMagenta
14 (fg/bg)256HighCyan
15 (fg/bg)256HighWhite
16..231 (fg/bg)256RNGNBN, where N are numbers from 0 to 5
232..255 (fg/bg)256GrayN, where N is a number from 0 to 23

And you can also use ready-made functions:

  • for colors:

    int rgb(int r, int g, int b); // r,g,b: 0..5
    int gray(int level); // level: 0..23
    
  • for ANSI escape codes:

    String fg256(int color); // color: 0..255
    String bg256(int color);
    String underline256(int color);
    

RGB colors #

https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit

A template for using a RGB color:

'$fgRgbOpen$r;$g;$b$fgRgbClose' // r,g,b: 0..255
'$bgRgbOpen$r;$g;$b$bgRgbClose'
'$underlineRgbOpen$r;$g;$b$underlineRgbClose'

You can also use ready-made functions:

String fgRgb(int r, int g, int b); // r,g,b: 0..255
String bgRgb(int r, int g, int b);
String underlineRgb(int r, int g, int b);

Control sequences #

Description Usage
cursor up '$cursorUpOpen$n$cursorUpClose' or cursorUp for n=1 or cursorUpN(int n)
cursor down '$cursorDownOpen$n$cursorDownClose' or cursorDownfor n=1 or cursorDownN(int n)
cursor forward '$cursorForwardOpen$n$cursorForwardClose' or cursorForward for n=1 or cursorForwardN(int n)
cursor back '$cursorBackOpen$n$cursorBackClose' or cursorBack for n=1 or cursorBackN(int n)
... ...
0
likes
0
points
41
downloads

Publisher

verified publisheryet-another.dev

Weekly Downloads

Yet another package for ANSI escape codes. It differs from the others only in that it focuses on using **constants** rather than functions or methods.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on ansi_escape_codes