Class TerminalTextStyle

java.lang.Object
org.aesh.terminal.formatting.TerminalTextStyle

public class TerminalTextStyle extends Object
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 Details

    • TerminalTextStyle

      public TerminalTextStyle()
      Create a default text style with no formatting.
    • TerminalTextStyle

      public TerminalTextStyle(CharacterType type)
      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 text
      faint - true for faint text
      italic - true for italic text
      underline - true for underlined text
      blink - true for blinking text
      invert - true for inverted colors
      crossedOut - 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

      public String toString()
      Overrides:
      toString in class Object
    • getLength

      public int getLength()
      Get the length of the ANSI escape sequence.
      Returns:
      the length of the style code string
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getValueComparedToPrev

      public String getValueComparedToPrev(TerminalTextStyle prev)
      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