Colors is a Kotlin library for changing the style of a string.
Colors has no dependencies (besides kotlin stdlib)
Be sure you have jcenter() as a repository
repositories {
jcenter()
}Add the dependency
implementation "com.saantiaguilera.colors:colors:latest.version"The library supports the colors defined per ANSI 3/4 bit colors. For changing to a specific color simply call it!
"This is black".black()
"This is red".red()
"This is blue".blue()
...If more than one is specified, it will use the last one.
"This is blue".red().green().blue()If you with to set background or foreground colors just:
"With red background".background(Colors.Color.RED)
"With red foreground".foreground(Colors.Color.RED)
"With red foreground".red()"Underlined".underline()
"Italic".italic()
"Bold".bold()
..."What should this be?".red().italic().bold().strikethrough()"Some red in italics".colorize(color = Colors.Color.RED, mode = Colors.Mode.ITALIC)Given a code like this:
We will get:
BSD License
Copyright (c) 2017-present. All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

