- All Implemented Interfaces:
Serializable,Comparable<Terminal>,Constable,org.refcodes.mixin.AliasAccessor
Enumeration with the (relevant) terminals as well as interpolated terminal
metrics.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTheTerminal.CharSetCapabilitydefines three categories of character capabilities as observed on various platform.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionansi: a terminal using the ANSI escape codes for color and formatting.cygwin: The cygwin terminal on Windows.gnome-terminal: the default terminal emulator for the GNOME desktop environment.konsole: the default terminal emulator for the KDE desktop environment.linux: the console terminal in a Linux system.rxvt:a terminal emulator for the X Window System.screen: a full-screen window manager that multiplexes a physical terminal between several processes.tmux: a terminal multiplexer that allows multiple terminals to be created and managed from a single console or SSH session.Unknown, not one of the others.vt100: a classic DEC terminalvt220: a popular terminal from Digital Equipment Corporation (DEC).xterm: a generic terminal emulator for the X Window System.xterm-256color: an extended version of xterm with support for 256 colors. -
Method Summary
Modifier and TypeMethodDescriptiongetAlias()Returns the alias by which thisTerminaltype is known.static StringDetermines the encoding of the system (system's console) in use as ofSystem.out.static intDetermines the height in characters of the system's terminal in use.static StringDetermines the operating system as ofOperatingSystem.toOperatingSystem()and in case aOperatingSystem.WINDOWSis being detected, then \r\n" (CRLF) is returned, else "\n" (LF) is returned.static StringDetermines the current session's terminal in use.static intgetWidth()Determines the width in characters of the system's terminal in use.static booleanDetermines whether ANSI escape sequences are supported by the terminal.static booleanDetermines whether ANSI escape sequences are forced to be supported or not by REFCODES.ORG artifacts.static booleanisLineBreakRequired(int aRowWidth) Determines whether we need an explicit line-break for the given width on the current operating system and used terminal.static Terminal.CharSetCapabilityDetermines theTerminal.CharSetCapabilityof the current terminal session.static StringtoLineBreak(int aRowWidth) UsesisLineBreakRequired(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 intDoes some calculation to always return a sound console height (never returns -1).static intDoes some calculation to always return a sound console width (never returns -1).static TerminalDetermines the terminal your application is currently in:static TerminalReturns the enum constant of this class with the specified name.static Terminal[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
XTERM
xterm: a generic terminal emulator for the X Window System. -
CYGWIN
cygwin: The cygwin terminal on Windows. -
VT100
vt100: a classic DEC terminal -
LINUX
linux: the console terminal in a Linux system. -
RXVT
rxvt:a terminal emulator for the X Window System. -
ANSI
ansi: a terminal using the ANSI escape codes for color and formatting. -
XTERM_256COLOR
xterm-256color: an extended version of xterm with support for 256 colors. -
VT220
vt220: a popular terminal from Digital Equipment Corporation (DEC). -
GNOME_TERMINAL
gnome-terminal: the default terminal emulator for the GNOME desktop environment. -
KONSOLE
konsole: the default terminal emulator for the KDE desktop environment. -
SCREEN
screen: a full-screen window manager that multiplexes a physical terminal between several processes. -
TMUX
tmux: a terminal multiplexer that allows multiple terminals to be created and managed from a single console or SSH session. -
UNKNOWN
Unknown, not one of the others.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getAlias
Returns the alias by which thisTerminaltype is known.- Specified by:
getAliasin interfaceorg.refcodes.mixin.AliasAccessor- Returns:
- The according
Terminaltypes alias.
-
getLineBreak
Determines the operating system as ofOperatingSystem.toOperatingSystem()and in case aOperatingSystem.WINDOWSis being detected, then \r\n" (CRLF) is returned, else "\n" (LF) is returned. Can be overridden with theSystemProperty.CONSOLE_LINE_BREAK(java -Dconsole.lineBreak=...) and theEnvironmentVariable.CONSOLE_LINE_BREAK("export CONSOLE_LINE_BREAK=...).- Returns:
- The operating system's specific line break; on Windows it is "\r\n" (CRLF) and on all other operating systems it is "\n" (LF).
-
getEncoding
Determines the encoding of the system (system's console) in use as ofSystem.out.- Returns:
- The encoding (of the console).
-
getHeight
public static int getHeight()Determines the height in characters of the system's terminal in use.- Returns:
- The height of the terminal in characters or -1 if the height cannot be determined.
-
getWidth
public static int getWidth()Determines the width in characters of the system's terminal in use.- Returns:
- The width of the terminal in characters or -1 if the width cannot be determined.
-
getTerminalSession
Determines the current session's terminal in use. Known terminal types can be retrieved viatoTerminal().- Returns:
- The current session's terminal in use.
-
isAnsiTerminal
public static boolean isAnsiTerminal()Determines whether ANSI escape sequences are supported by the terminal.- Returns:
- True in case ANSI escape sequences are supported, else false.
-
isAnsiTerminalPreferred
public static boolean isAnsiTerminalPreferred()Determines whether ANSI escape sequences are forced to be supported or not by REFCODES.ORG artifacts. This overrulesisAnsiTerminal()for the REFCODES.ORG artifacts. Various settings such asSystemProperty.CONSOLE_ANSIand (in this order)EnvironmentVariable.CONSOLE_ANSIoverruleisAnsiTerminal().- Returns:
- True in case ANSI escape sequences are forced to be used by REFCODES.ORG artifacts or not.
-
isLineBreakRequired
public static boolean isLineBreakRequired(int aRowWidth) Determines whether we need an explicit line-break for the given width on the current operating system and used terminal. E.g. on "win.cmd" we must not use a line-break in case our line is a s long as the console's width. There are some more such cases which this method tries to take into consideration.- Parameters:
aRowWidth- The row width you want to use when printing out to a console.- Returns:
- True in case you should use a line-break.
-
toLineBreak
UsesisLineBreakRequired(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).- Parameters:
aRowWidth- The row width you want to use when printing out to a console.- Returns:
- The system's line break characters when a line break is emphasized or an empty string if no line break sequence is recommended.
-
toPreferredHeight
public static int toPreferredHeight()Does some calculation to always return a sound console height (never returns -1). Anything in the REFCODES.ORG artifacts which is intended to print to the console uses this method to determine some heuristic best console height.- Returns:
- A sound heuristic console height.
-
toPreferredWidth
public static int toPreferredWidth()Does some calculation to always return a sound console width (never returns -1). Anything in the REFCODES.ORG artifacts which is intended to print to the console uses this method to determine some heuristic best console width.- Returns:
- A sound heuristic console width.
-
toCharSetCapability
Determines theTerminal.CharSetCapabilityof the current terminal session. TheTerminal.CharSetCapabilityis used to determine which characters to use when printing tables and boxes to the terminal (see theTableStyleclass'stoExecutionTableStylemethod as well as theTextBoxGridclass'stoExecutionTextBoxGrid()method.- Returns:
- The
Terminal.CharSetCapabilitydetermined at best knowledge.
-
toTerminal
Determines the terminal your application is currently in:
-