Skip to content

Commit 013694b

Browse files
committed
fix(styles): Adds background colors
1 parent 6b90683 commit 013694b

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

docs/reference/styles.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Just import them directly from bluebun.
66
## Usage
77

88
```typescript
9-
import { print, red, bold } from "bluebun"
9+
import { print, red, bold, bgGray } from "bluebun"
1010

11-
print(red(`This is ${bold("red")} text`))
11+
print(bgGray(red(`This is ${bold("red")} text on a gray background`)))
1212
```
1313

1414
## Available Styles and Colors

src/_types.d.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ export declare const brightBlue: (text: string) => string;
127127
export declare const brightMagenta: (text: string) => string;
128128
export declare const brightCyan: (text: string) => string;
129129
export declare const brightWhite: (text: string) => string;
130+
export declare const bgWhite: (text: string) => string;
131+
export declare const bgBlack: (text: string) => string;
132+
export declare const bgBlue: (text: string) => string;
133+
export declare const bgCyan: (text: string) => string;
134+
export declare const bgGreen: (text: string) => string;
135+
export declare const bgMagenta: (text: string) => string;
136+
export declare const bgRed: (text: string) => string;
137+
export declare const bgYellow: (text: string) => string;
138+
export declare const bgGrey: (text: string) => string;
139+
export declare const bgGray: (text: string) => string;
140+
export declare const bgBrightBlack: (text: string) => string;
141+
export declare const bgBrightRed: (text: string) => string;
142+
export declare const bgBrightGreen: (text: string) => string;
143+
export declare const bgBrightYellow: (text: string) => string;
144+
export declare const bgBrightBlue: (text: string) => string;
145+
export declare const bgBrightMagenta: (text: string) => string;
146+
export declare const bgBrightCyan: (text: string) => string;
147+
export declare const bgBrightWhite: (text: string) => string;
130148
export type AskOptions = {
131149
validation?: (answer: string) => true | string;
132150
after?: "preserve" | "clear";
@@ -161,6 +179,7 @@ export declare const cursorCodes: {
161179
readonly nextLine: "E";
162180
readonly previousLine: "F";
163181
readonly horizontalAbsolute: "G";
182+
readonly home: "H";
164183
readonly eraseData: "J";
165184
readonly eraseAfter: "0K";
166185
readonly eraseBefore: "1K";
@@ -193,6 +212,7 @@ export declare class Cursor {
193212
moveDown(count?: number): this;
194213
moveUp(count?: number): this;
195214
backToStart(): this;
215+
backToHome(): this;
196216
horizontalAbsolute(count?: number): this;
197217
eraseBefore(count?: number): this;
198218
eraseLine(): this;
@@ -207,9 +227,9 @@ export declare class Cursor {
207227
show(): this;
208228
backspace(count?: number): this;
209229
alternate(enabled: boolean): this;
230+
jump(name: string): this;
210231
queryPosition(): Promise<CursorPos>;
211232
bookmark(name: string, pos?: CursorPos): Promise<CursorPos>;
212-
jump(name: string): this;
213233
}
214234
export declare const cursor: Cursor;
215235
export declare function queryPosition(): Promise<CursorPos>;

src/styles.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,22 @@ export const brightBlue = color(ansiColors.brightBlue)
6161
export const brightMagenta = color(ansiColors.brightMagenta)
6262
export const brightCyan = color(ansiColors.brightCyan)
6363
export const brightWhite = color(ansiColors.brightWhite)
64+
65+
export const bgWhite = color(ansiColors.white + 10)
66+
export const bgBlack = color(ansiColors.black + 10)
67+
export const bgBlue = color(ansiColors.blue + 10)
68+
export const bgCyan = color(ansiColors.cyan + 10)
69+
export const bgGreen = color(ansiColors.green + 10)
70+
export const bgMagenta = color(ansiColors.magenta + 10)
71+
export const bgRed = color(ansiColors.red + 10)
72+
export const bgYellow = color(ansiColors.yellow + 10)
73+
export const bgGrey = color(ansiColors.grey + 10)
74+
export const bgGray = color(ansiColors.gray + 10)
75+
export const bgBrightBlack = color(ansiColors.brightBlack + 10)
76+
export const bgBrightRed = color(ansiColors.brightRed + 10)
77+
export const bgBrightGreen = color(ansiColors.brightGreen + 10)
78+
export const bgBrightYellow = color(ansiColors.brightYellow + 10)
79+
export const bgBrightBlue = color(ansiColors.brightBlue + 10)
80+
export const bgBrightMagenta = color(ansiColors.brightMagenta + 10)
81+
export const bgBrightCyan = color(ansiColors.brightCyan + 10)
82+
export const bgBrightWhite = color(ansiColors.brightWhite + 10)

0 commit comments

Comments
 (0)