开发者

How to use the Jansi library? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_开发问答 Closed 11 years ago.

I want to know how to use Jansi to print color in the command prompt on Windows.


From: http://www.rgagnon.com/javadetails/java-0047.html

import org.fusesource.jansi.AnsiConsole;

public class Test {
  public static final String ANSI_CLS = "\u001b[2J";
  public static final String ANSI_HOME = "\u001b[H";
  public static final String ANSI_BOLD = "\u001b[1m";
  public static final String ANSI_AT55 = "\u001b[10;10H";
  public static final String ANSI_REVERSEON = "\u001b[7m";
  public static final String ANSI_NORMAL = "\u001b[0m";
  public static final String ANSI_WHITEONBLUE = "\u001b[37;44m";

  public static void main(String args[]){
    AnsiConsole.systemInstall();
    AnsiConsole.out.println(ANSI_CLS);
    AnsiConsole.out.println
       (ANSI_AT55 + ANSI_REVERSEON + "Hello world" + ANSI_NORMAL);
    AnsiConsole.out.println
       (ANSI_HOME + ANSI_WHITEONBLUE + "Hello world" + ANSI_NORMAL);
    AnsiConsole.out.print
       (ANSI_BOLD + "Press a key..." + ANSI_NORMAL);
    try {System.in.read();}catch(Exception e){}
    AnsiConsole.out.println(ANSI_CLS);
    AnsiConsole.systemInstall();
    }
  }

And do not try to run within eclipse. The colors won't appear on eclipse console. Bundle it in a jar and run it on windows console i.e. command prompt.

For better result try to be more specific when asking questions, like, providing a link to the library which you are referring to and if possible whatever piece of code you have written.

By the way I got that link by just googling: Jansi+ANSI+Color

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜