Class AnsiProcessor

  • Direct Known Subclasses:
    ColorsAnsiProcessor, WindowsAnsiProcessor

    public class AnsiProcessor
    extends java.lang.Object
    ANSI processor providing process* corresponding to ANSI escape codes. This class methods implementations are empty: subclasses should actually perform the ANSI escape behaviors by implementing active code in process* methods.

    For more information about ANSI escape codes, see Wikipedia article

    Since:
    1.19
    • Constructor Detail

      • AnsiProcessor

        public AnsiProcessor​(java.io.OutputStream os)
    • Method Detail

      • getNextOptionInt

        protected int getNextOptionInt​(java.util.Iterator<java.lang.Object> optionsIterator)
                                throws java.io.IOException
        Helper for processEscapeCommand() to iterate over integer options
        Parameters:
        optionsIterator - the underlying iterator
        Throws:
        java.io.IOException - if no more non-null values left
      • processEscapeCommand

        protected boolean processEscapeCommand​(java.util.ArrayList<java.lang.Object> options,
                                               int command)
                                        throws java.io.IOException
        Returns:
        true if the escape command was processed.
        Throws:
        java.io.IOException
      • processOperatingSystemCommand

        protected boolean processOperatingSystemCommand​(java.util.ArrayList<java.lang.Object> options)
        Returns:
        true if the operating system command was processed.
      • processCharsetSelect

        protected boolean processCharsetSelect​(java.util.ArrayList<java.lang.Object> options)
        Process character set sequence.
        Parameters:
        options - options
        Returns:
        true if the charcter set select command was processed.
      • optionInt

        private int optionInt​(java.util.ArrayList<java.lang.Object> options,
                              int index)
      • optionInt

        private int optionInt​(java.util.ArrayList<java.lang.Object> options,
                              int index,
                              int defaultValue)
      • processRestoreCursorPosition

        protected void processRestoreCursorPosition()
                                             throws java.io.IOException
        Process CSI u ANSI code, corresponding to RCP – Restore Cursor Position
        Throws:
        java.io.IOException - IOException
      • processSaveCursorPosition

        protected void processSaveCursorPosition()
                                          throws java.io.IOException
        Process CSI s ANSI code, corresponding to SCP – Save Cursor Position
        Throws:
        java.io.IOException - IOException
      • processInsertLine

        protected void processInsertLine​(int optionInt)
                                  throws java.io.IOException
        Process CSI L ANSI code, corresponding to IL – Insert Line
        Parameters:
        optionInt - option
        Throws:
        java.io.IOException - IOException
        Since:
        1.16
      • processDeleteLine

        protected void processDeleteLine​(int optionInt)
                                  throws java.io.IOException
        Process CSI M ANSI code, corresponding to DL – Delete Line
        Parameters:
        optionInt - option
        Throws:
        java.io.IOException - IOException
        Since:
        1.16
      • processScrollDown

        protected void processScrollDown​(int optionInt)
                                  throws java.io.IOException
        Process CSI n T ANSI code, corresponding to SD – Scroll Down
        Parameters:
        optionInt - option
        Throws:
        java.io.IOException - IOException
      • processScrollUp

        protected void processScrollUp​(int optionInt)
                                throws java.io.IOException
        Process CSI n U ANSI code, corresponding to SU – Scroll Up
        Parameters:
        optionInt - option
        Throws:
        java.io.IOException - IOException
      • processEraseScreen

        protected void processEraseScreen​(int eraseOption)
                                   throws java.io.IOException
        Process CSI n J ANSI code, corresponding to ED – Erase in Display
        Parameters:
        eraseOption - eraseOption
        Throws:
        java.io.IOException - IOException
      • processEraseLine

        protected void processEraseLine​(int eraseOption)
                                 throws java.io.IOException
        Process CSI n K ANSI code, corresponding to ED – Erase in Line
        Parameters:
        eraseOption - eraseOption
        Throws:
        java.io.IOException - IOException
      • processSetForegroundColor

        protected void processSetForegroundColor​(int color)
                                          throws java.io.IOException
        process SGR 30-37 corresponding to Set text color (foreground).
        Parameters:
        color - the text color
        Throws:
        java.io.IOException - IOException
      • processSetForegroundColor

        protected void processSetForegroundColor​(int color,
                                                 boolean bright)
                                          throws java.io.IOException
        process SGR 30-37 or SGR 90-97 corresponding to Set text color (foreground) either in normal mode or high intensity.
        Parameters:
        color - the text color
        bright - is high intensity?
        Throws:
        java.io.IOException - IOException
      • processSetForegroundColorExt

        protected void processSetForegroundColorExt​(int paletteIndex)
                                             throws java.io.IOException
        process SGR 38 corresponding to extended set text color (foreground) with a palette of 255 colors.
        Parameters:
        paletteIndex - the text color in the palette
        Throws:
        java.io.IOException - IOException
      • processSetForegroundColorExt

        protected void processSetForegroundColorExt​(int r,
                                                    int g,
                                                    int b)
                                             throws java.io.IOException
        process SGR 38 corresponding to extended set text color (foreground) with a 24 bits RGB definition of the color.
        Parameters:
        r - red
        g - green
        b - blue
        Throws:
        java.io.IOException - IOException
      • processSetBackgroundColor

        protected void processSetBackgroundColor​(int color)
                                          throws java.io.IOException
        process SGR 40-47 corresponding to Set background color.
        Parameters:
        color - the background color
        Throws:
        java.io.IOException - IOException
      • processSetBackgroundColor

        protected void processSetBackgroundColor​(int color,
                                                 boolean bright)
                                          throws java.io.IOException
        process SGR 40-47 or SGR 100-107 corresponding to Set background color either in normal mode or high intensity.
        Parameters:
        color - the background color
        bright - is high intensity?
        Throws:
        java.io.IOException - IOException
      • processSetBackgroundColorExt

        protected void processSetBackgroundColorExt​(int paletteIndex)
                                             throws java.io.IOException
        process SGR 48 corresponding to extended set background color with a palette of 255 colors.
        Parameters:
        paletteIndex - the background color in the palette
        Throws:
        java.io.IOException - IOException
      • processSetBackgroundColorExt

        protected void processSetBackgroundColorExt​(int r,
                                                    int g,
                                                    int b)
                                             throws java.io.IOException
        process SGR 48 corresponding to extended set background color with a 24 bits RGB definition of the color.
        Parameters:
        r - red
        g - green
        b - blue
        Throws:
        java.io.IOException - IOException
      • processDefaultTextColor

        protected void processDefaultTextColor()
                                        throws java.io.IOException
        process SGR 39 corresponding to Default text color (foreground)
        Throws:
        java.io.IOException - IOException
      • processDefaultBackgroundColor

        protected void processDefaultBackgroundColor()
                                              throws java.io.IOException
        process SGR 49 corresponding to Default background color
        Throws:
        java.io.IOException - IOException
      • processAttributeReset

        protected void processAttributeReset()
                                      throws java.io.IOException
        process SGR 0 corresponding to Reset / Normal
        Throws:
        java.io.IOException - IOException
      • processCursorTo

        protected void processCursorTo​(int row,
                                       int col)
                                throws java.io.IOException
        process CSI n ; m H corresponding to CUP – Cursor Position or CSI n ; m f corresponding to HVP – Horizontal and Vertical Position
        Parameters:
        row - row
        col - col
        Throws:
        java.io.IOException - IOException
      • processCursorToColumn

        protected void processCursorToColumn​(int x)
                                      throws java.io.IOException
        process CSI n G corresponding to CHA – Cursor Horizontal Absolute
        Parameters:
        x - the column
        Throws:
        java.io.IOException - IOException
      • processCursorUpLine

        protected void processCursorUpLine​(int count)
                                    throws java.io.IOException
        process CSI n F corresponding to CPL – Cursor Previous Line
        Parameters:
        count - line count
        Throws:
        java.io.IOException - IOException
      • processCursorDownLine

        protected void processCursorDownLine​(int count)
                                      throws java.io.IOException
        process CSI n E corresponding to CNL – Cursor Next Line
        Parameters:
        count - line count
        Throws:
        java.io.IOException - IOException
      • processCursorLeft

        protected void processCursorLeft​(int count)
                                  throws java.io.IOException
        process CSI n D corresponding to CUB – Cursor Back
        Parameters:
        count - count
        Throws:
        java.io.IOException - IOException
      • processCursorRight

        protected void processCursorRight​(int count)
                                   throws java.io.IOException
        process CSI n C corresponding to CUF – Cursor Forward
        Parameters:
        count - count
        Throws:
        java.io.IOException - IOException
      • processCursorDown

        protected void processCursorDown​(int count)
                                  throws java.io.IOException
        process CSI n B corresponding to CUD – Cursor Down
        Parameters:
        count - count
        Throws:
        java.io.IOException - IOException
      • processCursorUp

        protected void processCursorUp​(int count)
                                throws java.io.IOException
        process CSI n A corresponding to CUU – Cursor Up
        Parameters:
        count - count
        Throws:
        java.io.IOException - IOException
      • processUnknownExtension

        protected void processUnknownExtension​(java.util.ArrayList<java.lang.Object> options,
                                               int command)
        Process Unknown Extension
        Parameters:
        options - options
        command - command
      • processChangeIconNameAndWindowTitle

        protected void processChangeIconNameAndWindowTitle​(java.lang.String label)
        process OSC 0;text BEL corresponding to Change Window and Icon label
        Parameters:
        label - window title name
      • processChangeIconName

        protected void processChangeIconName​(java.lang.String label)
        process OSC 1;text BEL corresponding to Change Icon label
        Parameters:
        label - icon label
      • processChangeWindowTitle

        protected void processChangeWindowTitle​(java.lang.String label)
        process OSC 2;text BEL corresponding to Change Window title
        Parameters:
        label - window title text
      • processUnknownOperatingSystemCommand

        protected void processUnknownOperatingSystemCommand​(int command,
                                                            java.lang.String param)
        Process unknown OSC command.
        Parameters:
        command - command
        param - param
      • processCharsetSelect

        protected void processCharsetSelect​(int set,
                                            char seq)