GithubHelp home page GithubHelp logo

dimo414 / f-ansi Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 33.39 MB

Terminal control API for Java; colored output and more

License: GNU General Public License v3.0

Java 100.00%
java ansi ansi-colors ansi-codes terminal shell console

f-ansi's People

Contributors

dimo414 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

f-ansi's Issues

Provide higher-level utilities for common tasks - AnsiUtils

Original report by Michael Diamond (Bitbucket: dimo414).


Examples:

  • Standard message templates:
    • [ OK ], [ WARN ], [ ERROR ] for statuses
    • [ INFO ], [ WARN ], [ ERROR ] (poor-man's logging) - no output control, just pretty formatting
    • [ DONE ], [ PASS ], [ SKIP ], [ FAIL ] for tasks / tests
  • Progress bar

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", "?");

Support colored output in Windows

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.

Create tests that inspect the colored output, rather than the raw codes

Original report by Michael Diamond (Bitbucket: dimo414).


See this question for background.

Resources:

Enable right-justified text

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.