Serializable
, Comparable<Terminal>
public enum Terminal extends Enum<Terminal>
Modifier and Type | Method | Description |
---|---|---|
static int |
getCurrentTerminalHeight() |
Determines the current height in characters of the system's terminal in
use.
|
static int |
getCurrentTerminalWidth() |
Determines the current width in characters of the system's terminal in
use.
|
static String |
getLineBreak() |
Determines the operating system as of
OperatingSystem.toOperatingSystem() and in case a
OperatingSystem.WINDOWS is being detected, then \r\n" (CRLF) is
returned, else "\n" (LF) is returned. |
static String |
getTerminalEncoding() |
Determines the encoding of the system (system's console) in use as of
System.out . |
static int |
getTerminalHeight() |
Determines the height in characters of the system's terminal in use.
|
static int |
getTerminalHeight(int aValidityTimeMillis) |
Determines the height in characters of the system's terminal in use.
|
static int |
getTerminalWidth() |
Determines the width in characters of the system's terminal in use.
|
static int |
getTerminalWidth(int aValidityTimeMillis) |
Determines the width in characters of the system's terminal in use.
|
static boolean |
isAnsiTerminal() |
Determines whether ANSI escape sequences are supported by the terminal.
|
static boolean |
isAnsiTerminalPreferred() |
Determines whether ANSI escape sequences are forced to be supported or
not by REFCODES.ORG artifacts.
|
static boolean |
isCurrentlyLineBreakRequired(int aRowWidth) |
Determines whether wee need an explicit line-break for the given width on
the current operating system and used terminal.
|
static boolean |
isLineBreakRequired(int aRowWidth) |
Determines whether wee need an explicit line-break for the given width on
the current operating system and used terminal.
|
static boolean |
isLineBreakRequired(int aRowWidth,
int aValidityTimeMillis) |
Determines whether wee need an explicit line-break for the given width on
the current operating system and used terminal.
|
static String |
toLineBreak(int aRowWidth) |
Uses
isLineBreakRequired(int) to retrieve the character sequence
required to suffix to a line in order to get a line break without risking
any empty lines as of automatic line wrapping. |
static int |
toPreferredTerminalHeight() |
Does some calculation to always return a sound console height (never
returns -1).
|
static int |
toPreferredTerminalWidth() |
Does some calculation to always return a sound console width (never
returns -1).
|
static Terminal |
toTerminal() |
Determines the terminal your application is currently in.
|
static Terminal |
valueOf(String name) |
Returns the enum constant of this type with the specified name.
|
static Terminal[] |
values() |
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Terminal XTERM
public static final Terminal CYGWIN
public static final Terminal UNKNOWN
public static Terminal[] values()
for (Terminal c : Terminal.values()) System.out.println(c);
public static Terminal valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static int getCurrentTerminalHeight()
getTerminalHeight()
or getTerminalHeight(int)
.public static int getCurrentTerminalWidth()
getTerminalWidth()
or getTerminalWidth(int)
.public static String getLineBreak()
OperatingSystem.toOperatingSystem()
and in case a
OperatingSystem.WINDOWS
is being detected, then \r\n" (CRLF) is
returned, else "\n" (LF) is returned. Can be overridden with the
SystemProperty.CONSOLE_LINE_BREAK
(java -Dconsole.lineBreak=...
) and the
EnvironmentVariable.CONSOLE_LINE_BREAK
("export CONSOLE_LINE_BREAK=...
).public static String getTerminalEncoding()
System.out
.public static int getTerminalHeight()
public static int getTerminalHeight(int aValidityTimeMillis)
aValidityTimeMillis
- The time period till last determination of
this value is valid, as determining this value is expensive.public static int getTerminalWidth()
public static int getTerminalWidth(int aValidityTimeMillis)
aValidityTimeMillis
- The time period till last determination of
this value is valid, as determining this value is expensive.public static boolean isAnsiTerminal()
public static boolean isAnsiTerminalPreferred()
isAnsiTerminal()
for the REFCODES.ORG artifacts. Various settings such as
SystemProperty.CONSOLE_ANSI
and (in this order)
EnvironmentVariable.CONSOLE_ANSI
overrule
isAnsiTerminal()
.public static boolean isCurrentlyLineBreakRequired(int aRowWidth)
isLineBreakRequired(int)
or
isLineBreakRequired(int, int)
.aRowWidth
- The row width you want to use when printing out to a
console.public static boolean isLineBreakRequired(int aRowWidth)
aRowWidth
- The row width you want to use when printing out to a
console.public static boolean isLineBreakRequired(int aRowWidth, int aValidityTimeMillis)
aRowWidth
- The row width you want to use when printing out to a
console.aValidityTimeMillis
- The time period till last determination of
this value is valid, as determining this value is expensive.public static String toLineBreak(int aRowWidth)
isLineBreakRequired(int)
to retrieve the character sequence
required to suffix to a line in order to get a line break without risking
any empty lines as of automatic line wrapping. Automatic line wrapping
can happen on Windows environment when the console width is reached. A
line break would cause a superfluous empty line (ugly).aRowWidth
- The row width you want to use when printing out to a
console.public static int toPreferredTerminalHeight()
public static int toPreferredTerminalWidth()
Copyright © 2021. All rights reserved.