dimo414 / f-ansi Goto Github PK
View Code? Open in Web Editor NEWTerminal control API for Java; colored output and more
License: GNU General Public License v3.0
Terminal control API for Java; colored output and more
License: GNU General Public License v3.0
Original report by Michael Diamond (Bitbucket: dimo414).
See this question for background.
Resources:
script
- examplexterm
's printerCommand
to get the terminal's text without escape sequences - it can also potentially write to HTMLOriginal report by Michael Diamond (Bitbucket: dimo414).
See sindresorhus/ansi-escapes#1 for a discussion and sindresorhus/ansi-escapes@31a29c3443 for a possible fix.
Original report by Michael Diamond (Bitbucket: dimo414).
Examples:
AnsiUtils
will contain non-fluent methods that utilize the Ansi
APIs. This simplifies the contracts, but does sacrifice some user control. Users can always just use Ansi
directly, however.
ansiUtil.ok("A %s message", "good");
An alternative would be to return Ansi
instances that have been seeded with additional output; this gives the user more flexibility but seemed more complex than beneficial.
ansiUtil.ok().outln("A %s message%s", "better", "?");
Original report by Michael Diamond (Bitbucket: dimo414).
It's easy to forget the terminating out/outln methods, using @CheckReturnValue
would help mitigate that.
Original report by Michael Diamond (Bitbucket: dimo414).
Low-priority. Add other lists of proprietary codes here.
Original report by Michael Diamond (Bitbucket: dimo414).
fixed() positions text relative to the top of the terminal, which can overwrite previous commands. A fixedBottom() command, that instead uses the lower-left corner as 1,1 and moves upwards would likely be more useful. It requires extracting the terminal's height, however, which is error-prone.
Blocked by issue #1.
Original report by Michael Diamond (Bitbucket: dimo414).
https://github.com/jnr/jnr-posix looks like a promising option; Java doesn't look to have anything reasonable out of the box.
Original report by Michael Diamond (Bitbucket: dimo414).
Jansi supports colored output, but via a closed-source native library. Reverse engineering or decompiling might be permitted under the project's Apache license, but even so it's not trivial.
F-ANSI works with Cygwin out of the box, so this will likely not be implemented unless someone is interested in making it happen.
E.g. to improve identifying COLUMNS
/LINES
. See http://mywiki.wooledge.org/BashFAQ/091
Original report by Michael Diamond (Bitbucket: dimo414).
Example syntax:
ansi().out("Message").rightJustify().out("[ ").color(GREEN).out("OK").out(" ]");
Should ouput (in an 80 column window):
Message [ OK ]
This is a little tricky since both the left- and right-justified text can have complex formatting, but we want to avoid just replicating the same logic twice. Ideally also rightJustify()
wouldn't just return an Ansi
instance since the right-justified text will have limited functionality (shouldn't be able to call rightJustify()
again, no cursor movement, etc.).
I'm also not certain whether this should live in Ansi
or AnsiUtils
. It feels a little complex for Ansi
, but it would fit nicely with it's fluent interface.
One idea would be for rightJustify()
to simply record the current buffer length and insert $COLUMNS - rightSide.length()
spaces at that index before outputting.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.