https://github.com/vindarel/format-colors
(format t "~/blue/ :)" "Hello")
https://github.com/vindarel/format-colors
Last synced: 5 months ago
JSON representation
(format t "~/blue/ :)" "Hello")
- Host: GitHub
- URL: https://github.com/vindarel/format-colors
- Owner: vindarel
- Created: 2020-10-02T15:07:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-06T15:48:25.000Z (over 5 years ago)
- Last Synced: 2025-04-05T22:28:58.661Z (about 1 year ago)
- Language: Common Lisp
- Size: 11.7 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple `format` directives to print in colors:
On [Ultralisp](https://ultralisp.org/).
~~~lisp
(format t "Hello ~/cyan/, are you a ~/green/ or ~/red/?" "you" "lisper" "not")
~~~
=>

Instead of (with `cl-ansi-text`):
~~~lisp
(use-package :cl-ansi-text)
(format t "Hello ~a, are you a ~a or ~a?" (cyan "you") (green "lisper") (red "not"))
;; or
;; (format t "Hello ~a, are you a ~a or ~a?" (cl-ansi-text:cyan "you") (cl-ansi-text:green "lisper") (cl-ansi-text:red "not"))
~~~
**Bold and italic modifiers**
Like all format directives, these can accept the `:` and `@` modifiers. `:` will be for `:`talic and `@` for b`@`ld.
"~:/blue/"
"~@/blue/"
There are also numerical parameters that we don't use.
It is possible to call the color functions directly, their signature is `stream arg colon-p at-sign-p &rest params`:
~~~lisp
(blue t "hello" nil nil)
~~~
## Install
~~~lisp
(use-package :format-colors)
;; or import from :format-colors the symbols :red :blue :yellow :green :cyan :black :white :magenta.
~~~
That's all. Let's see how it goes.
LLGPL
---
ps: to enable colors in Slime, one solution is [M-x slime-repl-ansi-on](https://github.com/deadtrickster/slime-repl-ansi-color/) (in MELPA).
``` lisp
(with-eval-after-load 'slime-repl
(require 'slime-repl-ansi-color))
(add-hook 'slime-repl-mode-hook 'slime-repl-ansi-color-mode)
```