Class WindowsAnsiProcessor


  • public final class WindowsAnsiProcessor
    extends AnsiProcessor
    A Windows ANSI escape processor, that uses JNA to access native platform API's to change the console attributes (see Jansi native Kernel32).

    The native library used is named jansi and is loaded using HawtJNI Runtime Library

    Since:
    1.19
    • Field Detail

      • console

        private final long console
      • FOREGROUND_YELLOW

        private static final short FOREGROUND_YELLOW
      • FOREGROUND_MAGENTA

        private static final short FOREGROUND_MAGENTA
      • FOREGROUND_CYAN

        private static final short FOREGROUND_CYAN
      • FOREGROUND_WHITE

        private static final short FOREGROUND_WHITE
      • BACKGROUND_YELLOW

        private static final short BACKGROUND_YELLOW
      • BACKGROUND_MAGENTA

        private static final short BACKGROUND_MAGENTA
      • BACKGROUND_CYAN

        private static final short BACKGROUND_CYAN
      • BACKGROUND_WHITE

        private static final short BACKGROUND_WHITE
      • ANSI_FOREGROUND_COLOR_MAP

        private static final short[] ANSI_FOREGROUND_COLOR_MAP
      • ANSI_BACKGROUND_COLOR_MAP

        private static final short[] ANSI_BACKGROUND_COLOR_MAP
      • originalColors

        private final short originalColors
      • negative

        private boolean negative
      • savedX

        private short savedX
      • savedY

        private short savedY
    • Constructor Detail

      • WindowsAnsiProcessor

        public WindowsAnsiProcessor​(java.io.OutputStream ps,
                                    long console)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • WindowsAnsiProcessor

        public WindowsAnsiProcessor​(java.io.OutputStream ps,
                                    boolean stdout)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • WindowsAnsiProcessor

        public WindowsAnsiProcessor​(java.io.OutputStream ps)
                             throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getConsoleInfo

        private void getConsoleInfo()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • applyAttribute

        private void applyAttribute()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • invertAttributeColors

        private short invertAttributeColors​(short attributes)
      • applyCursorPosition

        private void applyCursorPosition()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • processEraseScreen

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

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

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

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

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

        protected void processCursorUp​(int count)
                                throws java.io.IOException
        Description copied from class: AnsiProcessor
        process CSI n A corresponding to CUU – Cursor Up
        Overrides:
        processCursorUp in class AnsiProcessor
        Parameters:
        count - count
        Throws:
        java.io.IOException - IOException
      • processCursorTo

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

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

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

        protected void processCursorDownLine​(int count)
                                      throws java.io.IOException
        Description copied from class: AnsiProcessor
        process CSI n E corresponding to CNL – Cursor Next Line
        Overrides:
        processCursorDownLine in class AnsiProcessor
        Parameters:
        count - line count
        Throws:
        java.io.IOException - IOException
      • processSetForegroundColor

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

        protected void processSetForegroundColorExt​(int paletteIndex)
                                             throws java.io.IOException
        Description copied from class: AnsiProcessor
        process SGR 38 corresponding to extended set text color (foreground) with a palette of 255 colors.
        Overrides:
        processSetForegroundColorExt in class AnsiProcessor
        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
        Description copied from class: AnsiProcessor
        process SGR 38 corresponding to extended set text color (foreground) with a 24 bits RGB definition of the color.
        Overrides:
        processSetForegroundColorExt in class AnsiProcessor
        Parameters:
        r - red
        g - green
        b - blue
        Throws:
        java.io.IOException - IOException
      • processSetBackgroundColor

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

        protected void processSetBackgroundColorExt​(int paletteIndex)
                                             throws java.io.IOException
        Description copied from class: AnsiProcessor
        process SGR 48 corresponding to extended set background color with a palette of 255 colors.
        Overrides:
        processSetBackgroundColorExt in class AnsiProcessor
        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
        Description copied from class: AnsiProcessor
        process SGR 48 corresponding to extended set background color with a 24 bits RGB definition of the color.
        Overrides:
        processSetBackgroundColorExt in class AnsiProcessor
        Parameters:
        r - red
        g - green
        b - blue
        Throws:
        java.io.IOException - IOException
      • processDefaultTextColor

        protected void processDefaultTextColor()
                                        throws java.io.IOException
        Description copied from class: AnsiProcessor
        process SGR 39 corresponding to Default text color (foreground)
        Overrides:
        processDefaultTextColor in class AnsiProcessor
        Throws:
        java.io.IOException - IOException
      • processDefaultBackgroundColor

        protected void processDefaultBackgroundColor()
                                              throws java.io.IOException
        Description copied from class: AnsiProcessor
        process SGR 49 corresponding to Default background color
        Overrides:
        processDefaultBackgroundColor in class AnsiProcessor
        Throws:
        java.io.IOException - IOException
      • processAttributeReset

        protected void processAttributeReset()
                                      throws java.io.IOException
        Description copied from class: AnsiProcessor
        process SGR 0 corresponding to Reset / Normal
        Overrides:
        processAttributeReset in class AnsiProcessor
        Throws:
        java.io.IOException - IOException
      • processSaveCursorPosition

        protected void processSaveCursorPosition()
                                          throws java.io.IOException
        Description copied from class: AnsiProcessor
        Process CSI s ANSI code, corresponding to SCP – Save Cursor Position
        Overrides:
        processSaveCursorPosition in class AnsiProcessor
        Throws:
        java.io.IOException - IOException
      • processRestoreCursorPosition

        protected void processRestoreCursorPosition()
                                             throws java.io.IOException
        Description copied from class: AnsiProcessor
        Process CSI u ANSI code, corresponding to RCP – Restore Cursor Position
        Overrides:
        processRestoreCursorPosition in class AnsiProcessor
        Throws:
        java.io.IOException - IOException
      • processInsertLine

        protected void processInsertLine​(int optionInt)
                                  throws java.io.IOException
        Description copied from class: AnsiProcessor
        Process CSI L ANSI code, corresponding to IL – Insert Line
        Overrides:
        processInsertLine in class AnsiProcessor
        Parameters:
        optionInt - option
        Throws:
        java.io.IOException - IOException
      • processDeleteLine

        protected void processDeleteLine​(int optionInt)
                                  throws java.io.IOException
        Description copied from class: AnsiProcessor
        Process CSI M ANSI code, corresponding to DL – Delete Line
        Overrides:
        processDeleteLine in class AnsiProcessor
        Parameters:
        optionInt - option
        Throws:
        java.io.IOException - IOException
      • processChangeWindowTitle

        protected void processChangeWindowTitle​(java.lang.String label)
        Description copied from class: AnsiProcessor
        process OSC 2;text BEL corresponding to Change Window title
        Overrides:
        processChangeWindowTitle in class AnsiProcessor
        Parameters:
        label - window title text