|
| 1 | +package io.tnboot.logging.util.colorful |
| 2 | + |
| 3 | +fun reset(text: String) = RESET.style(text) |
| 4 | +fun bold(text: String) = BOLD.style(text) |
| 5 | +fun dim(text: String) = DIM.style(text) |
| 6 | +fun italic(text: String) = ITALIC.style(text) |
| 7 | +fun underline(text: String) = UNDERLINE.style(text) |
| 8 | +fun inverse(text: String) = INVERSE.style(text) |
| 9 | +fun hidden(text: String) = HIDDEN.style(text) |
| 10 | +fun strikeThrough(text: String) = STRIKETHROUGH.style(text) |
| 11 | +fun black(text: String) = BLACK.style(text) |
| 12 | +fun red(text: String) = RED.style(text) |
| 13 | +fun green(text: String) = GREEN.style(text) |
| 14 | +fun yellow(text: String) = YELLOW.style(text) |
| 15 | +fun blue(text: String) = BLUE.style(text) |
| 16 | +fun magenta(text: String) = MAGENTA.style(text) |
| 17 | +fun cyan(text: String) = CYAN.style(text) |
| 18 | +fun white(text: String) = WHITE.style(text) |
| 19 | +fun brightBlack(text: String) = BRIGHT_BLACK.style(text) |
| 20 | +fun brightRed(text: String) = BRIGHT_RED.style(text) |
| 21 | +fun brightGreen(text: String) = BRIGHT_GREEN.style(text) |
| 22 | +fun brightYellow(text: String) = BRIGHT_YELLOW.style(text) |
| 23 | +fun brightBlue(text: String) = BRIGHT_BLUE.style(text) |
| 24 | +fun brightMagenta(text: String) = BRIGHT_MAGENTA.style(text) |
| 25 | +fun brightCyan(text: String) = BRIGHT_CYAN.style(text) |
| 26 | +fun brightWhite(text: String) = BRIGHT_WHITE.style(text) |
| 27 | +fun bgBlack(text: String) = BG_BLACK.style(text) |
| 28 | +fun bgRed(text: String) = BG_RED.style(text) |
| 29 | +fun bgGreen(text: String) = BG_GREEN.style(text) |
| 30 | +fun bgYellow(text: String) = BG_YELLOW.style(text) |
| 31 | +fun bgBlue(text: String) = BG_BLUE.style(text) |
| 32 | +fun bgMagenta(text: String) = BG_MAGENTA.style(text) |
| 33 | +fun bgCyan(text: String) = BG_CYAN.style(text) |
| 34 | +fun bgWhite(text: String) = BG_WHITE.style(text) |
| 35 | +fun bgBrightBlack(text: String) = BG_BRIGHT_BLACK.style(text) |
| 36 | +fun bgBrightRed(text: String) = BG_BRIGHT_RED.style(text) |
| 37 | +fun bgBrightGreen(text: String) = BG_BRIGHT_GREEN.style(text) |
| 38 | +fun bgBrightYellow(text: String) = BG_BRIGHT_YELLOW.style(text) |
| 39 | +fun bgBrightBlue(text: String) = BG_BRIGHT_BLUE.style(text) |
| 40 | +fun bgBrightMagenta(text: String) = BG_BRIGHT_MAGENTA.style(text) |
| 41 | +fun bgBrightCyan(text: String) = BG_BRIGHT_CYAN.style(text) |
| 42 | +fun bgBrightWhite(text: String) = BG_BRIGHT_WHITE.style(text) |
| 43 | + |
| 44 | +@OptIn(ExperimentalUnsignedTypes::class) |
| 45 | +fun rgb8(color: UByte) = Code(39U, 38U, 5U, color) |
| 46 | + |
| 47 | +fun rgb8(str: String, color: UByte) = rgb8(color).style(str) |
| 48 | + |
| 49 | +@OptIn(ExperimentalUnsignedTypes::class) |
| 50 | +fun bgRgb8(color: UByte) = Code(49U, 48U, 5U, color) |
| 51 | + |
| 52 | +fun bgRgb8(str: String, color: UByte) = bgRgb8(color).style(str) |
| 53 | + |
| 54 | +@OptIn(ExperimentalUnsignedTypes::class) |
| 55 | +fun rgb24(r: UByte, g: UByte, b: UByte) = Code(39U, 38U, 2U, r, g, b) |
| 56 | + |
| 57 | +fun rgb24(str: String, r: UByte, g: UByte, b: UByte) = rgb24(r, g, b).style(str) |
| 58 | + |
| 59 | +fun rgb24(color: UInt) = rgb24( |
| 60 | + ((color shr 16) and 0xFFU).toUByte(), |
| 61 | + ((color shr 8) and 0xFFU).toUByte(), |
| 62 | + (color and 0xFFU).toUByte(), |
| 63 | +) |
| 64 | + |
| 65 | +fun rgb24(str: String, color: UInt) = rgb24(color).style(str) |
| 66 | + |
| 67 | +@OptIn(ExperimentalUnsignedTypes::class) |
| 68 | +fun bgRgb24(r: UByte, g: UByte, b: UByte) = Code(49U, 48U, 2U, r, g, b) |
| 69 | + |
| 70 | +fun bgRgb24(str: String, r: UByte, g: UByte, b: UByte) = bgRgb24(r, g, b).style(str) |
| 71 | + |
| 72 | +fun bgRgb24(color: UInt) = bgRgb24( |
| 73 | + ((color shr 16) and 0xFFU).toUByte(), |
| 74 | + ((color shr 8) and 0xFFU).toUByte(), |
| 75 | + (color and 0xFFU).toUByte(), |
| 76 | +) |
| 77 | + |
| 78 | +fun bgRgb24(str: String, color: UInt) = bgRgb24(color).style(str) |
0 commit comments