Package org.aesh.terminal.formatting
Class TerminalTextStyle
java.lang.Object
org.aesh.terminal.formatting.TerminalTextStyle
Specify a text style.
There are some values that nullify other values.
eg:
- specifying faint AND bold will nullify bold
bold AND italic will nullify bold
- Author:
- Ståle W. Pedersen
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a default text style with no formatting.TerminalTextStyle(boolean bold, boolean faint, boolean italic, boolean underline, boolean blink, boolean invert, boolean crossedOut) Create a text style with individual style options.Create a text style with the specified character type. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintGet the length of the ANSI escape sequence.Get the ANSI codes for this style relative to a previous style.inthashCode()booleanisBlink()Check if blink is enabled.booleanisBold()Check if bold is enabled.booleanCheck if conceal is enabled.booleanCheck if crossed out is enabled.booleanisFaint()Check if faint is enabled.booleanCheck if any formatting is applied.booleanisInvert()Check if invert is enabled.booleanisItalic()Check if italic is enabled.booleanCheck if underline is enabled.voidsetBlink(boolean blink) Set the blink state.voidsetBold(boolean bold) Set the bold state.voidsetConceal(boolean conceal) Set the conceal state.voidsetCrossedOut(boolean crossedOut) Set the crossed out state.voidsetInvert(boolean invert) Set the invert state.voidsetItalic(boolean italic) Set the italic state.voidsetUnderline(boolean underline) Set the underline state.toString()
-
Constructor Details
-
TerminalTextStyle
public TerminalTextStyle()Create a default text style with no formatting. -
TerminalTextStyle
Create a text style with the specified character type.- Parameters:
type- the character type to apply
-
TerminalTextStyle
public TerminalTextStyle(boolean bold, boolean faint, boolean italic, boolean underline, boolean blink, boolean invert, boolean crossedOut) Create a text style with individual style options.- Parameters:
bold- true for bold textfaint- true for faint textitalic- true for italic textunderline- true for underlined textblink- true for blinking textinvert- true for inverted colorscrossedOut- true for strikethrough text
-
-
Method Details
-
isBold
public boolean isBold()Check if bold is enabled.- Returns:
- true if bold
-
setBold
public void setBold(boolean bold) Set the bold state.- Parameters:
bold- true to enable bold
-
isFaint
public boolean isFaint()Check if faint is enabled.- Returns:
- true if faint
-
isItalic
public boolean isItalic()Check if italic is enabled.- Returns:
- true if italic
-
setItalic
public void setItalic(boolean italic) Set the italic state.- Parameters:
italic- true to enable italic
-
isUnderline
public boolean isUnderline()Check if underline is enabled.- Returns:
- true if underlined
-
setUnderline
public void setUnderline(boolean underline) Set the underline state.- Parameters:
underline- true to enable underline
-
isBlink
public boolean isBlink()Check if blink is enabled.- Returns:
- true if blinking
-
setBlink
public void setBlink(boolean blink) Set the blink state.- Parameters:
blink- true to enable blinking
-
isInvert
public boolean isInvert()Check if invert is enabled.- Returns:
- true if colors are inverted
-
setInvert
public void setInvert(boolean invert) Set the invert state.- Parameters:
invert- true to invert colors
-
isCrossedOut
public boolean isCrossedOut()Check if crossed out is enabled.- Returns:
- true if strikethrough
-
setCrossedOut
public void setCrossedOut(boolean crossedOut) Set the crossed out state.- Parameters:
crossedOut- true to enable strikethrough
-
isConceal
public boolean isConceal()Check if conceal is enabled.- Returns:
- true if concealed
-
setConceal
public void setConceal(boolean conceal) Set the conceal state.- Parameters:
conceal- true to hide text
-
isFormatted
public boolean isFormatted()Check if any formatting is applied.- Returns:
- true if any style option is enabled
-
toString
-
getLength
public int getLength()Get the length of the ANSI escape sequence.- Returns:
- the length of the style code string
-
equals
-
hashCode
public int hashCode() -
getValueComparedToPrev
Get the ANSI codes for this style relative to a previous style. Only outputs codes for attributes that differ from the previous style.- Parameters:
prev- the previous text style- Returns:
- the ANSI codes for changed attributes
-