All Projects → pnathan → Cl Ansi Text

pnathan / Cl Ansi Text

Enables ANSI colors for printing.

Programming Languages

lisp
113 projects

Projects that are alternatives of or similar to Cl Ansi Text

line
An easy to use golang package for stylizing terminal output
Stars: ✭ 26 (-13.33%)
Mutual labels:  colors, ansi-colors
kolorist
A tiny utility to colorize stdin/stdout
Stars: ✭ 160 (+433.33%)
Mutual labels:  colors, ansi-colors
log-utils
Basic logging utils: colors, symbols and timestamp.
Stars: ✭ 24 (-20%)
Mutual labels:  colors, ansi-colors
Ansi Colors
Easily add ANSI colors to your text and symbols in the terminal. ansi-colors is the official ansi styling library for gulp, and is used by hundreds of other projects, including mocha and enquirer.
Stars: ✭ 300 (+900%)
Mutual labels:  ansi-colors, colors
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+105446.67%)
Mutual labels:  ansi-colors
Gradle Test Logger Plugin
A Gradle plugin for printing beautiful logs on the console while running tests
Stars: ✭ 460 (+1433.33%)
Mutual labels:  ansi-colors
Colorful
Terminal string styling done right, in Python 🐍 🎉
Stars: ✭ 456 (+1420%)
Mutual labels:  colors
Pterm
✨ #PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.
Stars: ✭ 449 (+1396.67%)
Mutual labels:  ansi-colors
Git Praise
A nicer git blame.
Stars: ✭ 24 (-20%)
Mutual labels:  colors
Django Admin Interface
django's default admin interface made customizable. popup windows replaced by modals. :mage: ⚡️
Stars: ✭ 717 (+2290%)
Mutual labels:  colors
Pastel
Terminal output styling with intuitive and clean API.
Stars: ✭ 569 (+1796.67%)
Mutual labels:  colors
Iroiro
Beautiful Colors Lookup in CLI
Stars: ✭ 470 (+1466.67%)
Mutual labels:  colors
Flowing Gradient
Android Library to make a flowing gradient effect, similar to that used in Instagram Android login screen
Stars: ✭ 701 (+2236.67%)
Mutual labels:  colors
Nord
An arctic, north-bluish color palette.
Stars: ✭ 4,816 (+15953.33%)
Mutual labels:  colors
Styled System
⬢ Style props for rapid UI development
Stars: ✭ 7,126 (+23653.33%)
Mutual labels:  colors
2048.c
Console version of the game "2048" for GNU/Linux
Stars: ✭ 453 (+1410%)
Mutual labels:  ansi-colors
Termenv
Advanced ANSI style & color support for your terminal applications
Stars: ✭ 555 (+1750%)
Mutual labels:  colors
Colored
(Rust) Coloring terminal so simple you already know how to do it !
Stars: ✭ 715 (+2283.33%)
Mutual labels:  colors
Termcolor
Termcolor is a header-only C++ library for printing colored messages to the terminal. Written just for fun with a help of the Force.
Stars: ✭ 533 (+1676.67%)
Mutual labels:  colors
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (+1596.67%)
Mutual labels:  colors

cl-ansi-text

Because color in your terminal is nice. CI

Installation: (ql:quickload :cl-ansi-text)

Usage example -

The main macro is with-color, which creates an enviroment where everything that is put on stream gets colored according to color.

Color options comes in several forms.

Keyword Symbol

Basic 8 colors in the 3-bit color mode are supported, which are :black, :red, :green, :yellow, :blue, :magenta, :cyan and :white.

* (with-color (:red)
    (princ "Gets printed red...")
    (princ "and this too!"))
; Gets printed red...and this too!
; => "and this too!"

CL-COLORS:RGB and CL-COLORS:HSV object

These are color structures from CL-COLORS2 (a maintained fork of CL-COLORS). CL-COLORS2 has several constants e.g. cl-colors:+red+ that holds the corresponding color values. CL-COLORS2 also supports useful blending operations on colors. Note that CL-COLORS2 library provides a package CL-COLORS, not CL-COLORS2.

Hex representation

These are CSS-style color strings such as "#FF0000".

Integer as a 24-bit color

It treats an integer as a hex string. The bottom 8 bit is used for the blue, the 8th to 16th bits are used for green, the 16th to 24th bits are used for red. Remaining bits are ignored.

List of numbers as a 24-bit color

It takes a list of three numbers (RGB) between 0 and 256.

Function interface for printing in specific colors

We provide shorthand functions for generating a colored strings:

* (yellow "Yellow string")
; => "Yellow string"
* (princ (yellow "String with yellow background" :style :background))
; "String with yellow background"
; => "String with yellow background"
* (princ
   (concatenate
    'string
    (yellow "Five") " test results went " (red "terribly wrong") "!"))
; Five test results went terribly wrong!
; => "Five test results went terribly wrong!"

You can bind the *enabled* special variable to nil to control the colorization:

* (let (cl-ansi-text:*enabled*)
    (princ (red "This string is printed normally")))

API

Type color-specifier

(or unsigned-byte
    (cons (real 0 256)
          (cons (real 0 256)
                (cons (real 0 256)
                      nil)))
    cl-colors:rgb
    cl-colors:hsv
    term-colors
    color-string)

Type term-colors

(member :black :red :green :yellow :blue :magenta :cyan :white)

Type color-string

A string of length 3, 4, 6, or 7, that optionally starts with a #, and the rest consists of 3 or 6 hexademical alphadigits (case-insensitive).

Macro with-color

with-color (color &key (stream t) (effect :unset) (style :foreground)) &body body

Writes out the ANSI escape code string denoting effect, style, and a switch to color, then executes body, then writes out the string that resets the decoration.

Function make-color-string

make-color-string color &key (effect :unset) (style :foreground) enabled

Takes an object of color-specifier and returns a string sufficient to change to the given color.

Colorization is controlled by enabled unless manually specified otherwise by :enabled keyword.

Function black, red, green, yellow, blue, magenta, cyan, white

Shortcut functions that takes a single argument, string, and returns a string decorated by the corresponding color.

Special variable *enabled*

Turns on/off the colorization.

Special variable *color-mode*

Controls the way make-color-string emits the color code.

It should be one of the following keyword symbols: :3bit, :8bit, :24bit. The specified color is converted to the nearest color in the color space. The default value is :8bit.

Note that the actual appearance of the screen in the :3bit mode may be affected by the terminal setting -- For example, many terminals do not use FF0000 for the red.

Constant +reset-color-string+

A constant string that resets the color state of the terminal.

Running test

Run ./testscr.ros with Roswell. You can also manually run the test with (ql:quickload :cl-ansi-text.test) (fiveam:run! :cl-ansi-text).

CI tests

You can view the list of lisp implementation this library is tested on the Github Action tab. The testing environment is Linux, but we believe this should work also on OSX.

Note

Note that your terminal MUST be ANSI-compliant to show these colors.

SLIME REPL does not display these colors by default (2019.12.13). To make it understand the ANSI escape sequence, install slime-repl-ansi-color package available from MELPA using package-install and add the following in .emacs:

(with-eval-after-load 'slime-repl
  (require 'slime-repl-ansi-color))
(add-hook 'slime-repl-mode-hook 'slime-repl-ansi-color-mode)

License: LLGPL

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].