Class DoubleSizeCharacters


  • public class DoubleSizeCharacters
    extends java.lang.Object
    Utility class for handling double-size characters in terminals.

    Double-size characters are a feature supported by some terminals that allows displaying text at double width and/or double height. This is useful for creating banners, headers, or emphasizing important text.

    The implementation uses VT100-compatible escape sequences: - ESC # 3: Double-height, double-width line (top half) - ESC # 4: Double-height, double-width line (bottom half) - ESC # 5: Single-width, single-height line (normal) - ESC # 6: Double-width, single-height line

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DoubleSizeCharacters.Mode
      Enumeration of double-size character modes.
    • Constructor Summary

      Constructors 
      Constructor Description
      DoubleSizeCharacters()
      Creates a new DoubleSizeCharacters instance.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isDoubleSizeSupported​(Terminal terminal)
      Checks if the terminal supports double-size characters.
      static void printBanner​(Terminal terminal, java.lang.String text, char borderChar)
      Creates a banner with the specified text using double-height characters.
      static void printDoubleHeight​(Terminal terminal, java.lang.String text)
      Prints text in double height (both top and bottom halves).
      static void printDoubleWidth​(Terminal terminal, java.lang.String text)
      Prints text in double width.
      static void printNormal​(Terminal terminal, java.lang.String text)
      Prints text in normal size.
      static void reset​(Terminal terminal)
      Resets the terminal to normal character size.
      static void setMode​(Terminal terminal, DoubleSizeCharacters.Mode mode)
      Sets the double-size character mode for the current line.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DoubleSizeCharacters

        public DoubleSizeCharacters()
        Creates a new DoubleSizeCharacters instance.
    • Method Detail

      • isDoubleSizeSupported

        public static boolean isDoubleSizeSupported​(Terminal terminal)
        Checks if the terminal supports double-size characters.
        Parameters:
        terminal - the terminal to check
        Returns:
        true if the terminal supports double-size characters, false otherwise
      • setMode

        public static void setMode​(Terminal terminal,
                                   DoubleSizeCharacters.Mode mode)
                            throws java.io.IOException
        Sets the double-size character mode for the current line.
        Parameters:
        terminal - the terminal to write to
        mode - the double-size mode to set
        Throws:
        java.io.IOException - if an I/O error occurs
      • printNormal

        public static void printNormal​(Terminal terminal,
                                       java.lang.String text)
                                throws java.io.IOException
        Prints text in normal size.
        Parameters:
        terminal - the terminal to write to
        text - the text to print
        Throws:
        java.io.IOException - if an I/O error occurs
      • printDoubleWidth

        public static void printDoubleWidth​(Terminal terminal,
                                            java.lang.String text)
                                     throws java.io.IOException
        Prints text in double width.
        Parameters:
        terminal - the terminal to write to
        text - the text to print
        Throws:
        java.io.IOException - if an I/O error occurs
      • printDoubleHeight

        public static void printDoubleHeight​(Terminal terminal,
                                             java.lang.String text)
                                      throws java.io.IOException
        Prints text in double height (both top and bottom halves). This method automatically handles printing both the top and bottom halves of double-height text.
        Parameters:
        terminal - the terminal to write to
        text - the text to print
        Throws:
        java.io.IOException - if an I/O error occurs
      • printBanner

        public static void printBanner​(Terminal terminal,
                                       java.lang.String text,
                                       char borderChar)
                                throws java.io.IOException
        Creates a banner with the specified text using double-height characters. This is useful for creating prominent headers or titles.
        Parameters:
        terminal - the terminal to write to
        text - the text for the banner
        borderChar - the character to use for the border (e.g., '*', '=', '-')
        Throws:
        java.io.IOException - if an I/O error occurs
      • reset

        public static void reset​(Terminal terminal)
                          throws java.io.IOException
        Resets the terminal to normal character size. This is useful to ensure the terminal is in a known state.
        Parameters:
        terminal - the terminal to reset
        Throws:
        java.io.IOException - if an I/O error occurs