This is an ANSI Escape Sequence Emulator library written entirely in QB64-PE.
- No dependency on third party libraries
- Works on Windows, Linux & macOS
- Works in 32bpp graphics mode emulating text mode colors and true color extensions
- Supports most common ANSI escape sequences and even some obscure ones
- All relevant ANSI Escape Sequences
- All relevant ANSI.SYS Escape Sequences
- PabloDraw 24bpp color escape sequence
- Supports embedded ANSI music - WIP
- Supports ANSImation content
- Support querying width and height of the content in characters - WIP
- Easy plug-&-play API - OK
- Loads and renders ANS, ASC, DIZ, NFO and TXT files
- Includes a demo viewer to show how to use the library
- Clone the repository to a directory of your choice
- Open Terminal and change to the directory using an appropriate OS command
- Run
git submodule update --init --recursive
to initialize, fetch and checkout git submodules - Open ANSIPrint64.bas in the QB64-PE IDE and press
F5
to compile and run - To use the library in your project add the Toolbox64 repository as a Git submodule
' Easy top-level API (call and forget style)
SUB ANSI_Print (sANSI AS STRING)
' Core library functions (if more control is required)
SUB ANSI_InitializeEmulator
SUB ANSI_ResetEmulator
SUB ANSI_SetEmulationSpeed (nCPS AS LONG)
FUNCTION ANSI_PrintCharacter%% (ch AS _UNSIGNED _BYTE)
FUNCTION ANSI_PrintString%% (s AS STRING)
' Library support functions
SUB ANSI_SetTextCanvasColor (c AS _UNSIGNED LONG, isBackground AS LONG, isLegacy AS LONG)
FUNCTION ANSI_GetTextCanvasWidth&
FUNCTION ANSI_GetTextCanvasHeight&
SUB ANSI_ClearTextCanvasArea (l AS LONG, t AS LONG, r AS LONG, b AS LONG)
What can I do with this?
- Anything you want! Use it in games, demos or for writing pretty text mode user interfaces and output.
Can you implement feature x / y?
- With the limited time I have between my day job, home and family, there is only so much I can do. I do maintain a list of TODO (see below). However, those do not have any set deadlines. If you need something implemented, submit a GitHub issue about it or do it yourself and submit a PR.
I found a bug. How can I help?
- Let me know using GitHub issues or fix it yourself and submit a PR!
Can this be used in a game / demo?
- Absolutely. The demo code included in a good example.
- This requires the latest version of QB64-PE
- The renderer is designed for QB64's 32BPP graphics Window. Legacy
SCREEN
s will not work - This is WIP. So, expect things to change and break. There are some bugs and quirks that needs to be worked out
- When you clone a repository that contains submodules, the submodules are not automatically cloned by default
- You will need to use the
git submodule update --init --recursive
to initialize, fetch and checkout git submodules
- ANSI Escape Sequences by Christian Petersen
- ANSI escape code from Wikipedia
- ANSI.SYS from Wikipedia
- Console Virtual Terminal Sequences by Microsoft
- ANSI.SYS Documentation by Microsoft
- ANSI.SYS Documentation and Reference by Carsten Cumbrowski
- ANSIPLUS Escape Sequences by Kristofer Sweger
- NANSI.SYS Documentation by Daniel Kegel
- NNANSI.COM Documentation by Tom Almy
- ANSI Color Codes by Jimmy Tang
- SAUCE – Standard Architecture for Universal Comment Extensions by Olivier "Tasmaniac" Reubens / ACiD
- ANSI Music by unknown
- Various resources and information from https://16colo.rs/, http://www.roysac.com/ and https://int10h.org/
Icon by DesignContest
Rick Christy (grymmjack) for pointing out issues and helping me with invaluable resources. This project includes some of his artwork for testing. Thanks Rick!