AsciiStyledString extension
Styling a string by chaining onto it, instead of gluing codes around it by hand.
print(
'ready'
.foreground(const AsciiColour.rgb(5, 2, 0)) // the 6x6x6 cube
.background(const AsciiColourRgb(0x33, 0x66, 0x99)) // 24-bit
.underlineColour(const AsciiColour.gray(12)) // one of the 24 greys
.underline,
);
Each link adds its code to the run in front of the string and closes the whole with reset — and because it only adds that reset when the string does not already end in one, a chain of any length still ends with exactly one.
Codes come out in the order they were chained, which is the order a terminal is likeliest to honour. Most read them as flags and would not care, but the ones that resolve a style the moment it arrives do: a terminal that implements dim by mixing the foreground into the background computes that mix when it sees the code, so a colour arriving afterwards replaces the result and the text comes out at full strength. Chain the colour first and the dim last, as the sentence reads.
What the trailing reset also means is that a styled string is finished.
Chaining onto 'a'.bold + 'b' styles nothing further — the reset from
.bold sits in the middle, and .foreground would wrap both halves and
paint only up to it. Style each piece, then join.
- on
Properties
- alternativeFont1 → String
-
Available on String, provided by the AsciiStyledString extension
First alternative font — ALTERNATIVE_FONT_1.no setter - alternativeFont2 → String
-
Available on String, provided by the AsciiStyledString extension
Second alternative font — ALTERNATIVE_FONT_2.no setter - alternativeFont3 → String
-
Available on String, provided by the AsciiStyledString extension
Third alternative font — ALTERNATIVE_FONT_3.no setter - alternativeFont4 → String
-
Available on String, provided by the AsciiStyledString extension
Fourth alternative font — ALTERNATIVE_FONT_4.no setter - alternativeFont5 → String
-
Available on String, provided by the AsciiStyledString extension
Fifth alternative font — ALTERNATIVE_FONT_5.no setter - alternativeFont6 → String
-
Available on String, provided by the AsciiStyledString extension
Sixth alternative font — ALTERNATIVE_FONT_6.no setter - alternativeFont7 → String
-
Available on String, provided by the AsciiStyledString extension
Seventh alternative font — ALTERNATIVE_FONT_7.no setter - alternativeFont8 → String
-
Available on String, provided by the AsciiStyledString extension
Eighth alternative font — ALTERNATIVE_FONT_8.no setter - alternativeFont9 → String
-
Available on String, provided by the AsciiStyledString extension
Ninth alternative font — ALTERNATIVE_FONT_9.no setter - blink → String
-
Available on String, provided by the AsciiStyledString extension
Blink, under 150 per minute — BLINK.no setter - blinkRapid → String
-
Available on String, provided by the AsciiStyledString extension
Blink, 150 per minute or more — BLINK_RAPID.no setter - bold → String
-
Available on String, provided by the AsciiStyledString extension
Bold, or increased intensity — BOLD.no setter - curlyUnderline → String
-
Available on String, provided by the AsciiStyledString extension
Curly (wavy) underline — CURLY_UNDERLINE.no setter - dashedUnderline → String
-
Available on String, provided by the AsciiStyledString extension
Dashed underline — DASHED_UNDERLINE.no setter - dim → String
-
Available on String, provided by the AsciiStyledString extension
Dim, or decreased intensity — DIM.no setter - dottedUnderline → String
-
Available on String, provided by the AsciiStyledString extension
Dotted underline — DOTTED_UNDERLINE.no setter - doublyUnderline → String
-
Available on String, provided by the AsciiStyledString extension
Double underline — DOUBLY_UNDERLINE.no setter - encircle → String
-
Available on String, provided by the AsciiStyledString extension
Draws a circle around the text — ENCIRCLE.no setter - fraktur → String
-
Available on String, provided by the AsciiStyledString extension
Fraktur (Gothic) — FRAKTUR. Honoured by very little.no setter - frame → String
-
Available on String, provided by the AsciiStyledString extension
Draws a frame around the text — FRAME.no setter - ideogramDoublyOverline → String
-
Available on String, provided by the AsciiStyledString extension
Ideogram double overline — IDEOGRAM_DOUBLY_OVERLINE.no setter - ideogramDoublyUnderline → String
-
Available on String, provided by the AsciiStyledString extension
Ideogram double underline — IDEOGRAM_DOUBLY_UNDERLINE.no setter - ideogramOverline → String
-
Available on String, provided by the AsciiStyledString extension
Ideogram overline, or a line down the left side — IDEOGRAM_OVERLINE.no setter - ideogramStress → String
-
Available on String, provided by the AsciiStyledString extension
Ideogram stress marking — IDEOGRAM_STRESS.no setter - ideogramUnderline → String
-
Available on String, provided by the AsciiStyledString extension
Ideogram underline, or a line down the right side — IDEOGRAM_UNDERLINE.no setter - inverse → String
-
Available on String, provided by the AsciiStyledString extension
Swaps foreground and background — INVERSE.no setter - invisible → String
-
Available on String, provided by the AsciiStyledString extension
Hides the text, which is still there to select and copy — INVISIBLE.no setter - italic → String
-
Available on String, provided by the AsciiStyledString extension
Italic — ITALIC.no setter - overline → String
-
Available on String, provided by the AsciiStyledString extension
A line above the text — OVERLINE.no setter - proportionalSpacing → String
-
Available on String, provided by the AsciiStyledString extension
Proportional spacing — PROPORTIONAL_SPACING.no setter - strikethrough → String
-
Available on String, provided by the AsciiStyledString extension
Strikethrough — STRIKETHROUGH.no setter - subscript → String
-
Available on String, provided by the AsciiStyledString extension
Subscript — SUBSCRIPT.no setter - superscript → String
-
Available on String, provided by the AsciiStyledString extension
Superscript — SUPERSCRIPT.no setter - underline → String
-
Available on String, provided by the AsciiStyledString extension
Underline — UNDERLINE.no setter
Methods
-
background(
AsciiInk colour) → String -
Available on String, provided by the AsciiStyledString extension
Paints the background behind the text. -
foreground(
AsciiInk colour) → String -
Available on String, provided by the AsciiStyledString extension
Paints the text, from either colour table. -
styled(
String code) → String -
Available on String, provided by the AsciiStyledString extension
Opens with a code this extension has no name for, for anything hand-rolled out of CSI and SGR. -
underlineColor(
AsciiInk colour) → String -
Available on String, provided by the AsciiStyledString extension
underlineColour under the other spelling. -
underlineColour(
AsciiInk colour) → String -
Available on String, provided by the AsciiStyledString extension
Paints the underline, leaving the text its own colour.