March 25, 2022

console-colors is a reboot of the colorize[1] package, a library for colors in your terminal.

DUB: https://code.dlang.org/packages/console-colors
GitHub: https://github.com/p0nce/console-colors

Features:

  • in-band color information like colorize.
  • 16 colors, foreground and background. Caution not all colors are adequate on various terminals.
  • HTML-like tags for colors instead of VT-100 escape codes. Some chars must be escaped with entities: > < and &, this is what the escapeCCL(string s) function does.
    import consolecolors;
    cwriteln("<lblue>this is light blue</lblue>");
  • 32 UFCS short functions like .red and .on_white.
  • Colors are stacked, when you exit a color if will restore the former.
  • Separate exception type for exceptions with coloured messages: CCLException.
    Handy for nice compiler messages.
  • like the "colorize" package, coloured string must print through cwrite[f][ln] function.
  • globally disable console colors, with disableConsoleColors().

[1] https://code.dlang.org/packages/colorize

February 25

New in console-colors v1.3.1:

  • Possibility to enable UTF-8 codepage in Windows terminal: call enableConsoleUTF8() at start-up.
  • Use VT100 escaped codes when supported in Windows (some Windows 10+and later). It's a bit faster.
  • Bold text with <b>text</b>, <strong>text</strong> or .in_bold() call (VT-100 only)
  • Italic text with <em>text</em>, <i>text</i> or .in_italic() call (VT-100 only)
  • Blinking text with <blink>text</blink> or .in_blink() call (VT-100 only)
  • Underlined text with <u>text</u> or .in_underline() call (VT-100 only)

DUB: https://code.dlang.org/packages/console-colors

You can see what you can do with dub test console-colors.
Or alternatively running the examples/simple example from the repo.