https://github.com/dimo414/f-ansi
Terminal control API for Java; colored output and more
https://github.com/dimo414/f-ansi
ansi ansi-codes ansi-colors console java shell terminal
Last synced: 9 months ago
JSON representation
Terminal control API for Java; colored output and more
- Host: GitHub
- URL: https://github.com/dimo414/f-ansi
- Owner: dimo414
- License: gpl-3.0
- Created: 2020-01-17T09:29:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-29T18:47:19.000Z (about 6 years ago)
- Last Synced: 2025-02-02T04:41:13.525Z (over 1 year ago)
- Topics: ansi, ansi-codes, ansi-colors, console, java, shell, terminal
- Language: Java
- Homepage:
- Size: 32.6 MB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# F-ANSI - Java Colored Output
[](https://github.com/dimo414/f-ansi/releases/0.3)
[](https://dimo414.github.io/f-ansi/0.3/)
[](https://github.com/dimo414/f-ansi/issues)
[](https://github.com/dimo414/f-ansi/blob/master/LICENSE)
*A fluent Java API to control console output via ANSI control codes*
## Background
Console output doesn't have to be boring black and white, but creating visually
appealing command line programs isn't straightforward. The standard mechanism,
[ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code), are
confusing and tedious to work with. F-ANSI provides an intuitive, fluent
abstraction to create elegant applications without the hassle.
## Usage
**In Beta**: F-ANSI is still in active development, and the API may change. See
Guava's
[Beta API](https://github.com/google/guava/wiki/PhilosophyExplained#beta-apis)
policy for more.
F-ANSI's fluent interface allows you to compose readable chains of output; the
following example prints "Foo" in red, followed by a hyphen in the terminal's
default styling, followed by "Bar" in green.
ansi().color(RED).out("Foo").out(" - ").color(LIGHT_GREEN).outln("Bar");

There are several demo scripts in the [demo](/demo/demo) directory you can use
for reference and testing. To print a color table of the default ANSI colors,
you can call `demo.ColorTable`:

## Dependencies
F-ANSI depends on [Guava](https://github.com/google/guava). The tests further
depend on [TestNG](testng.org/) and [Truth](https://github.com/google/truth).
For convenience the `f-ansi-no-dependencies.jar` bundles in Guava, at the cost
of a much larger Jar. If you already have Guava on your classpath, the
`f-ansi.jar` is much smaller.
## Copyright
Copyright 2016-2017 Michael Diamond
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .