Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A collection of useful ANSI escape sequences and helper functions
ResourceFunction["ANSITools"][token] generates ANSI escape codes corresponding to token. | |
ResourceFunction["ANSITools"]["MoveCursor", args] generates ANSI escape codes moving the terminal cursor as directed by args. | |
ResourceFunction["ANSITools"]["Style", text, styleOptions] generates ANSI escape codes styling text using the styleOptions provided. | |
ResourceFunction["ANSITools"]["Style", styleOptions] operator form of Style able to applied directly to text strings. |
| "MoveCursor" | row,column or direction,amount | move the cursor to a specified position or by a specified amount |
| "Style" | text, styleoptions | style text according to the styleoptions |
| FontColor | Default | change the foreground color of text |
| FontWeight | Default | change the text display mode |
| Background | Default | change the background color of text |
| "SavePosition" | save the current cursor postion |
| "LoadPosition" | load the last saved cursor position |
| "RequestPosition" | request the cursor position (reports as ESC[{row};{col}R) |
| "SaveScreen" | save the current screen |
| "RestoreScreen" | restores the saved screen |
| "AlternativeBuffer" | creates an alternative output buffer |
| "RestoreBuffer" | restores screen back to the main buffer |
| "ShowCursor" | makes the cursor visible |
| "HideCursor" | makes the cursor invisible |
| "Clear" | clear the entire screen |
| "ClearToStart" | clear from cursor to start of the screen |
| "ClearToEnd" | clear from cursor to end of the screen |
| "ClearLine" | clear the entire line |
| "ClearLineToStart" | clear from cursor to start of the line |
| "ClearLineToEnd" | clear from cursor to end of the line |
| "Tokens" | list all known tokens |
List all known tokens:
| In[1]:= |
| Out[1]= |
Style some text printed in the console:

Commands can be linked together using StringJoin. Delete the last 10 rows printed in the terminal:

Use the operator form of "Style":
| In[2]:= |
| Out[3]= |
ANSITools will always output some string containing ANSI escape sequences:
| In[4]:= | ![]() |
| Out[4]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License