Skip to content

ThatsNasu/Ansi

Repository files navigation

Ansi - Formatting with Escapes made easy

Build Version Discord channel

Ansi is an easy to use library for easier text formatting with ANSI Escape Sequences by providing the required methods, while keeping the API lightweight and logical. Its written in and for Java. Despite being in an early stage, it already saves a lot of work and implementation. If you want to help me improve this library further, feel free to open Issues, fork this Project for your own use or post questions as well as answers to already existing questions.


Do you have some questions about this library that are not covered by the wiki, or want to help improving it? Feel free to join us on our Discord Server.

Adding this library as dependency

is pretty straight forward. Just grab the jar file and add it to your projects dependencies, or use one of the following build tools.

If you are using Gradle

add the following line to your dependencies:

implementation 'dev.thatsnasu:Ansi:1.1.1'

For Maven

it would be:

<dependency>
    <groupId>dev.thatsnasu</groupId>
    <artifactId>Ansi</artifactId>
    <version>1.1.1</version>
</dependency>

For everything else

Visit maven central and pick the release you like to find the code you need.

Features

  • Predefined, ready to use Colors and Formats
  • Combining Colors and Formats as you like
  • Storing Color and Format-presets for reuse

How to use

Check out the Getting started section.

Some words about my Motivation

Writing several Java Programs, i noticed that i often reuse my own code from Project to Project, namely logging mechanisms and Colorization with ANSI Escape Sequences. Memorizing this Sequences is hard, using a library with an easy to use API for it isn't. Refurbishing Code will do once in a while, but on the long run its hard to maintain across multiple projects, so i started developing this library to have to change only one part of the code and on the same time give others the opportunity to use it aswell.

Special Thanks goes to

  • netcode, for helping me on questions, problems, sorting my head, finding better solutions and overall helping me improving my code.
  • the creator of name that color. I retrieved most of the color names with this tool.