Class Console

java.lang.Object
com.codename1.cli.Console

public final class Console extends Object

What a command needs to know about the terminal it writes to.

Answered from the environment, the conventions command-line tools share: COLUMNS for the width, NO_COLOR and CLICOLOR_FORCE for color, and TERM for whether the output is a terminal that understands color at all.

  • Method Details

    • width

      public static int width()
      The width help text is wrapped to: COLUMNS when it holds a number, otherwise 80.
    • colorEnabled

      public static boolean colorEnabled()
      Whether style(String, Console.Style...) adds color: never when NO_COLOR is set, always when CLICOLOR_FORCE is set to anything but 0, and otherwise when TERM names a terminal other than dumb and standard output is a terminal, so output piped to a file or another program carries no escape codes.
    • isTerminal

      public static boolean isTerminal()
      Whether standard output is a terminal rather than a pipe or a file.
    • style

      public static String style(String text, Console.Style... styles)
      text with ANSI escapes for styles around it, or text itself when colorEnabled() says no.