21

ANSI art and animations were prevalent on BBS systems in the late 80s and early 90s, and the ANSI art scene continues to thrive today. There are thousands of ANSI art files, with usual extension .ans, available on the Internet, many from those retro BBS's, and many recent artists' works too.

Screenshot ANSII art

I would like to easily recreate the experience of viewing ANSI art online by viewing .ans files natively, just using a terminal window and command-line tool to display the text. Based on my limited understanding of ANSI art, I think several retro-computing environmental conditions would need to be emulated within the terminal session. Off the top of my head:

  1. Recreate the ANSI code page definitions, including all the escape codes that were commonly used in ANSI art. In the old days, I think the MS-DOS "ANSI.SYS" device driver provided this.
  2. Choose a suitable font that displays all the ANSI text characters in a manner true to the original online experience.
  3. Ditto for the color palette utilized on old EGA and VGA displays. I think both 16-color and 256-color palettes were common.
  4. Simulate appropriate output speed of characters to the terminal, allowing files to be viewed as if they were received over a modem connection at, for example, a speed of 9600 baud.

To summarize, if there was an ideal solution, it would work as simply as this:

ansi-cat http://ansiart.mydomain.net/some_ansi_art.ans --baud=9600

And the tool would fetch and display the .ans file in the terminal window using a simulated 9600 bps. Of course, a cross-platform tool is best, but I suppose there are valid reasons this might be more easily accomplished on some modern platforms than others.

Naturally, I will be thrilled with any answer that can come close to this simple experience. I would rather not have to rely on emulation software and old DOS programs to display the art.

20

There are various ANSI art viewers for modern platforms which satisfy all your feature requirements (command-line syntax excepted), for example:

Inside a terminal, at least on Linux/Unix and presumably macOS, viewing ASCII/ANSI art boils down to setting the font and colours, and slowing the display down — terminals support the required escape codes. One setup that works quite nicely is to use the Ultimate Oldschool PC Font Pack, and run xterm with the appropriate options: ansiterm provides a good base, you'll just want to change the font name (e.g. -fa "Px437 IBM VGA9" instead of -fn dos437), and change the geometry to 80×25 for some DOS files. Inside the terminal, use slowcat to slow the output:

./slowcat -d 1000000 bambi.vt

for bambi.vt for example.

You can also use less to view files of static images:

LESSCHARSET=dos less -R CL\!-1999.ANS
  • One thing none of the answers seem to have mentioned is that some commands were processed slightly differently by different terminals; some "ANSI art" files are written so as to be processed uniformly (e.g. selecting a black background before doing a clear-to-end-of-line will yield the same behavior on terminals that set the background on the cleared characters to black as with those that set it to the current background color) but some will only look good on emulators that behave a particular way. I've not seen any good summary of emulator behavioral differences, though. – supercat Jun 14 '18 at 15:50
7

I got bored over the weekend and created Ansi-Cat for a Windows command prompt.

https://github.com/peteri/Ansi-Cat

Does code page 437 -> Unicode conversion, tested it on Windows 8.1 & 10 but you will need the .net framework version 4.5.2 to run it. It's a bit rough (error handling just prints the exception) but works for 16 color .ans files I've tried from archive.org but doesn't deal with blink commands.

If you give it a go and run into problems add them to the GitHub issues pages.

  • Also see github.com/adoxa/ansicon – Leo B. Mar 14 '17 at 0:06
  • Nice find @LeoB. Much more useful if you need Ansi for real work. – PeterI Mar 14 '17 at 9:05
  • Excellent! This compliments Stephen's answer above nicely by adding Windows support for a console-based method. – Brian H Mar 14 '17 at 17:00
  • Thanks I can recommend writing a ansi parser as a coding kata, I still need to finish off by adding a few more tests but it seems a shame to let it languish on my hard disk. – PeterI Mar 14 '17 at 18:38
  • @PeterI I've converted my comment to an answer for easier reference. – Leo B. Mar 14 '17 at 18:39
4

The ANSICON tool "provides ANSI escape sequences for Windows console programs. It provides much the same functionality as ANSI.SYS does for MS-DOS".

It can start an ANSI-capable instance of the command processor, or display standard input if redirected, or execute a specified program in an ANSI-capable window.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.