Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class Console
- Object
- Console
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.
Nested types
enum Console.Style | The styles style can apply. |
Methods
public static int width() | The width help text is wrapped to: COLUMNS when it holds a number, otherwise 80. |
public static boolean colorEnabled() | Whether 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. |
public static boolean isTerminal() | Whether standard output is a terminal rather than a pipe or a file. |
public static String style(String text, Console.Style... styles) | text with ANSI escapes for styles around it, or text itself when colorEnabled says no. |
Inherited methods
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 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)