Files
funkpower 74a684c269 ansi: show ANSI art in a UTF-8 terminal, or as plain or shaded text
Draws an .ans file into a grid the way an ANSI-BBS terminal would (cursor
moves, the wrap at the SAUCE width, iCE colours) and writes it out as UTF-8:
in colour, --plain, or --mono with coloured areas shaded by brightness. info
prints the SAUCE record. One C99 file with no dependencies.
2026-10-22 19:30:17 -04:00

39 lines
1.3 KiB
Markdown

# ansi
Show ANSI art in a modern terminal, or turn it into plain text.
An `.ans` file is CP437 text with ANSI colour and cursor codes, laid out for an
80-column BBS terminal that wraps it. Converting it with `iconv` gets the
characters right but not the layout: a lot of art has no line breaks at all, and
much of it moves the cursor around. `ansi` draws the file into a grid the way a
BBS terminal would, then writes the grid out as UTF-8 lines.
```console
$ ansi piece.ans | less -R # in colour
$ ansi --mono piece.ans > piece.txt # no colour, coloured areas as shading
$ ansi --plain piece.ans # the characters only
$ ansi info piece.ans # title, artist, group, date and size
$ curl -s https://16colo.rs/pack/dd26/raw/dd-cola.ans | ansi
```
`--mono` is for places that show no colour, like newsgroups and mail. Each
coloured area is redrawn by how bright its colour looks, so art built from
coloured spaces keeps its shape instead of going blank.
It follows the SAUCE record for the width, shows blinking backgrounds bright
(iCE colour), and reads standard input when given no file or `-`.
## Install
One C99 file, no dependencies.
```console
$ make
$ make install # into ~/bin and ~/share/man/man1
$ make install PREFIX=/usr/local
```
## Licence
GPL-2.0. See `LICENSE`.