mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
feat(std/fmt): add bright color variations (#7241)
This commit is contained in:
parent
d6dc797d15
commit
8ca903f649
2 changed files with 128 additions and 0 deletions
|
@ -120,9 +120,41 @@ export function white(str: string): string {
|
|||
}
|
||||
|
||||
export function gray(str: string): string {
|
||||
return brightBlack(str);
|
||||
}
|
||||
|
||||
export function brightBlack(str: string): string {
|
||||
return run(str, code([90], 39));
|
||||
}
|
||||
|
||||
export function brightRed(str: string): string {
|
||||
return run(str, code([91], 39));
|
||||
}
|
||||
|
||||
export function brightGreen(str: string): string {
|
||||
return run(str, code([92], 39));
|
||||
}
|
||||
|
||||
export function brightYellow(str: string): string {
|
||||
return run(str, code([93], 39));
|
||||
}
|
||||
|
||||
export function brightBlue(str: string): string {
|
||||
return run(str, code([94], 39));
|
||||
}
|
||||
|
||||
export function brightMagenta(str: string): string {
|
||||
return run(str, code([95], 39));
|
||||
}
|
||||
|
||||
export function brightCyan(str: string): string {
|
||||
return run(str, code([96], 39));
|
||||
}
|
||||
|
||||
export function brightWhite(str: string): string {
|
||||
return run(str, code([97], 39));
|
||||
}
|
||||
|
||||
export function bgBlack(str: string): string {
|
||||
return run(str, code([40], 49));
|
||||
}
|
||||
|
@ -155,6 +187,38 @@ export function bgWhite(str: string): string {
|
|||
return run(str, code([47], 49));
|
||||
}
|
||||
|
||||
export function bgBrightBlack(str: string): string {
|
||||
return run(str, code([100], 49));
|
||||
}
|
||||
|
||||
export function bgBrightRed(str: string): string {
|
||||
return run(str, code([101], 49));
|
||||
}
|
||||
|
||||
export function bgBrightGreen(str: string): string {
|
||||
return run(str, code([102], 49));
|
||||
}
|
||||
|
||||
export function bgBrightYellow(str: string): string {
|
||||
return run(str, code([103], 49));
|
||||
}
|
||||
|
||||
export function bgBrightBlue(str: string): string {
|
||||
return run(str, code([104], 49));
|
||||
}
|
||||
|
||||
export function bgBrightMagenta(str: string): string {
|
||||
return run(str, code([105], 49));
|
||||
}
|
||||
|
||||
export function bgBrightCyan(str: string): string {
|
||||
return run(str, code([106], 49));
|
||||
}
|
||||
|
||||
export function bgBrightWhite(str: string): string {
|
||||
return run(str, code([107], 49));
|
||||
}
|
||||
|
||||
/* Special Color Sequences */
|
||||
|
||||
function clampAndTruncate(n: number, max = 255, min = 0): number {
|
||||
|
|
|
@ -87,6 +87,38 @@ Deno.test("testGray", function (): void {
|
|||
assertEquals(c.gray("foo bar"), "[90mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightBlack", function (): void {
|
||||
assertEquals(c.brightBlack("foo bar"), "[90mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightRed", function (): void {
|
||||
assertEquals(c.brightRed("foo bar"), "[91mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightGreen", function (): void {
|
||||
assertEquals(c.brightGreen("foo bar"), "[92mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightYellow", function (): void {
|
||||
assertEquals(c.brightYellow("foo bar"), "[93mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightBlue", function (): void {
|
||||
assertEquals(c.brightBlue("foo bar"), "[94mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightMagenta", function (): void {
|
||||
assertEquals(c.brightMagenta("foo bar"), "[95mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightCyan", function (): void {
|
||||
assertEquals(c.brightCyan("foo bar"), "[96mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBrightWhite", function (): void {
|
||||
assertEquals(c.brightWhite("foo bar"), "[97mfoo bar[39m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBlack", function (): void {
|
||||
assertEquals(c.bgBlack("foo bar"), "[40mfoo bar[49m");
|
||||
});
|
||||
|
@ -119,6 +151,38 @@ Deno.test("testBgWhite", function (): void {
|
|||
assertEquals(c.bgWhite("foo bar"), "[47mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightBlack", function (): void {
|
||||
assertEquals(c.bgBrightBlack("foo bar"), "[100mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightRed", function (): void {
|
||||
assertEquals(c.bgBrightRed("foo bar"), "[101mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightGreen", function (): void {
|
||||
assertEquals(c.bgBrightGreen("foo bar"), "[102mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightYellow", function (): void {
|
||||
assertEquals(c.bgBrightYellow("foo bar"), "[103mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightBlue", function (): void {
|
||||
assertEquals(c.bgBrightBlue("foo bar"), "[104mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightMagenta", function (): void {
|
||||
assertEquals(c.bgBrightMagenta("foo bar"), "[105mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightCyan", function (): void {
|
||||
assertEquals(c.bgBrightCyan("foo bar"), "[106mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testBgBrightWhite", function (): void {
|
||||
assertEquals(c.bgBrightWhite("foo bar"), "[107mfoo bar[49m");
|
||||
});
|
||||
|
||||
Deno.test("testClampUsingRgb8", function (): void {
|
||||
assertEquals(c.rgb8("foo bar", -10), "[38;5;0mfoo bar[39m");
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue