Top Description Fields Constructors Methods
org.fusesource.jansi.io

public final Class WindowsAnsiProcessor

extends AnsiProcessor
Class Inheritance
Imports
java.io.IOException, .OutputStream, org.fusesource.jansi.internal.Kernel32, .Kernel32.CONSOLE_SCREEN_BUFFER_INFO, .Kernel32.COORD

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 Summary

Modifier and TypeField and Description
private static final short[]
private static final short[]
private static final short
private static final short
private static final short
private static final short
private static final short
private final long
private static final short
private static final short
private static final short
private static final short
private static final short
private final Kernel32.CONSOLE_SCREEN_BUFFER_INFO
private boolean
private final short
private short
private short
Inherited from org.fusesource.jansi.io.AnsiProcessor:
ATTRIBUTE_BLINK_FASTATTRIBUTE_BLINK_OFFATTRIBUTE_BLINK_SLOWATTRIBUTE_CONCEAL_OFFATTRIBUTE_CONCEAL_ONATTRIBUTE_INTENSITY_BOLDATTRIBUTE_INTENSITY_FAINTATTRIBUTE_INTENSITY_NORMALATTRIBUTE_ITALICATTRIBUTE_NEGATIVE_OFFATTRIBUTE_NEGATIVE_ONATTRIBUTE_UNDERLINEATTRIBUTE_UNDERLINE_DOUBLEATTRIBUTE_UNDERLINE_OFFBLACKBLUECYANERASE_LINEERASE_LINE_TO_BEGININGERASE_LINE_TO_ENDERASE_SCREENERASE_SCREEN_TO_BEGININGERASE_SCREEN_TO_ENDGREENMAGENTAosREDWHITEYELLOW

Constructor Summary

AccessConstructor and Description
public
public
WindowsAnsiProcessor(OutputStream ps, boolean stdout)

public

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
private short
invertAttributeColors(short attributes)

protected void
processAttributeReset()

Overrides org.fusesource.jansi.io.AnsiProcessor.processAttributeReset.

process SGR 0 corresponding to Reset / Normal
protected void
processChangeWindowTitle(String
window title text
label
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processChangeWindowTitle.

process OSC 2;text BEL corresponding to Change Window title
protected void
processCursorDown(int
count
count
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorDown.

process CSI n B corresponding to CUD – Cursor Down
protected void
processCursorDownLine(int
line count
count
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorDownLine.

process CSI n E corresponding to CNL – Cursor Next Line
protected void
processCursorLeft(int
count
count
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorLeft.

process CSI n D corresponding to CUB – Cursor Back
protected void
processCursorRight(int
count
count
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorRight.

process CSI n C corresponding to CUF – Cursor Forward
protected void
processCursorTo(int
row
row
,
int
col
col
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorTo.

process CSI n ; m H corresponding to CUP – Cursor Position or CSI n ; m f corresponding to HVP – Horizontal and Vertical Position
protected void
processCursorToColumn(int
the column
x
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorToColumn.

process CSI n G corresponding to CHA – Cursor Horizontal Absolute
protected void
processCursorUp(int
count
count
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorUp.

process CSI n A corresponding to CUU – Cursor Up
protected void
processCursorUpLine(int
line count
count
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorUpLine.

process CSI n F corresponding to CPL – Cursor Previous Line
protected void
processDefaultBackgroundColor()

Overrides org.fusesource.jansi.io.AnsiProcessor.processDefaultBackgroundColor.

process SGR 49 corresponding to Default background color
protected void
processDefaultTextColor()

Overrides org.fusesource.jansi.io.AnsiProcessor.processDefaultTextColor.

process SGR 39 corresponding to Default text color (foreground)
protected void
processDeleteLine(int
option
optionInt
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processDeleteLine.

Process CSI M ANSI code, corresponding to DL – Delete Line
protected void
processEraseLine(int
eraseOption
eraseOption
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processEraseLine.

Process CSI n K ANSI code, corresponding to ED – Erase in Line
protected void
processEraseScreen(int
eraseOption
eraseOption
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processEraseScreen.

Process CSI n J ANSI code, corresponding to ED – Erase in Display
protected void
processInsertLine(int
option
optionInt
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processInsertLine.

Process CSI L ANSI code, corresponding to IL – Insert Line
protected void
processRestoreCursorPosition()

Overrides org.fusesource.jansi.io.AnsiProcessor.processRestoreCursorPosition.

Process CSI u ANSI code, corresponding to RCP – Restore Cursor Position
protected void
processSaveCursorPosition()

Overrides org.fusesource.jansi.io.AnsiProcessor.processSaveCursorPosition.

Process CSI s ANSI code, corresponding to SCP – Save Cursor Position
protected void
processSetAttribute(int
attribute
attribute
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetAttribute.

process SGR other than 0 (reset), 30-39 (foreground), 40-49 (background), 90-97 (foreground high intensity) or 100-107 (background high intensity)
protected void
processSetBackgroundColor(int
the background color
color
,
boolean
is high intensity?
bright
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColor.

process SGR 40-47 or SGR 100-107 corresponding to Set background color either in normal mode or high intensity.
protected void
processSetBackgroundColorExt(int
the background color in the palette
paletteIndex
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColorExt.

process SGR 48 corresponding to extended set background color with a palette of 255 colors.
protected void
processSetBackgroundColorExt(int
red
r
,
int
green
g
,
int
blue
b
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColorExt.

process SGR 48 corresponding to extended set background color with a 24 bits RGB definition of the color.
protected void
processSetForegroundColor(int
the text color
color
,
boolean
is high intensity?
bright
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColor.

process SGR 30-37 or SGR 90-97 corresponding to Set text color (foreground) either in normal mode or high intensity.
protected void
processSetForegroundColorExt(int
the text color in the palette
paletteIndex
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColorExt.

process SGR 38 corresponding to extended set text color (foreground) with a palette of 255 colors.
protected void
processSetForegroundColorExt(int
red
r
,
int
green
g
,
int
blue
b
)

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColorExt.

process SGR 38 corresponding to extended set text color (foreground) with a 24 bits RGB definition of the color.
Inherited from org.fusesource.jansi.io.AnsiProcessor:
getNextOptionIntprocessChangeIconNameprocessChangeIconNameAndWindowTitleprocessCharsetSelectprocessCharsetSelectprocessEscapeCommandprocessOperatingSystemCommandprocessScrollDownprocessScrollUpprocessSetBackgroundColorprocessSetForegroundColorprocessUnknownExtensionprocessUnknownOperatingSystemCommand

Field Detail

ANSI_BACKGROUND_COLOR_MAPback to summary
private static final short[] ANSI_BACKGROUND_COLOR_MAP
ANSI_FOREGROUND_COLOR_MAPback to summary
private static final short[] ANSI_FOREGROUND_COLOR_MAP
BACKGROUND_BLACKback to summary
private static final short BACKGROUND_BLACK
BACKGROUND_CYANback to summary
private static final short BACKGROUND_CYAN
BACKGROUND_MAGENTAback to summary
private static final short BACKGROUND_MAGENTA
BACKGROUND_WHITEback to summary
private static final short BACKGROUND_WHITE
BACKGROUND_YELLOWback to summary
private static final short BACKGROUND_YELLOW
consoleback to summary
private final long console
FOREGROUND_BLACKback to summary
private static final short FOREGROUND_BLACK
FOREGROUND_CYANback to summary
private static final short FOREGROUND_CYAN
FOREGROUND_MAGENTAback to summary
private static final short FOREGROUND_MAGENTA
FOREGROUND_WHITEback to summary
private static final short FOREGROUND_WHITE
FOREGROUND_YELLOWback to summary
private static final short FOREGROUND_YELLOW
infoback to summary
private final Kernel32.CONSOLE_SCREEN_BUFFER_INFO info
negativeback to summary
private boolean negative
originalColorsback to summary
private final short originalColors
savedXback to summary
private short savedX
savedYback to summary
private short savedY

Constructor Detail

WindowsAnsiProcessorback to summary
public WindowsAnsiProcessor(OutputStream ps, long console) throws IOException
WindowsAnsiProcessorback to summary
public WindowsAnsiProcessor(OutputStream ps, boolean stdout) throws IOException
WindowsAnsiProcessorback to summary
public WindowsAnsiProcessor(OutputStream ps) throws IOException

Method Detail

applyAttributeback to summary
private void applyAttribute() throws IOException
applyCursorPositionback to summary
private void applyCursorPosition() throws IOException
getConsoleInfoback to summary
private void getConsoleInfo() throws IOException
invertAttributeColorsback to summary
private short invertAttributeColors(short attributes)
processAttributeResetback to summary
protected void processAttributeReset() throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processAttributeReset.

Doc from org.fusesource.jansi.io.AnsiProcessor.processAttributeReset.

process SGR 0 corresponding to Reset / Normal

Annotations
@Override
Exceptions
IOException:
IOException
processChangeWindowTitleback to summary
protected void processChangeWindowTitle(String label)

Overrides org.fusesource.jansi.io.AnsiProcessor.processChangeWindowTitle.

Doc from org.fusesource.jansi.io.AnsiProcessor.processChangeWindowTitle.

process OSC 2;text BEL corresponding to Change Window title

Parameters
label:String

window title text

Annotations
@Override
processCursorDownback to summary
protected void processCursorDown(int count) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorDown.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorDown.

process CSI n B corresponding to CUD – Cursor Down

Parameters
count:int

count

Annotations
@Override
Exceptions
IOException:
IOException
processCursorDownLineback to summary
protected void processCursorDownLine(int count) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorDownLine.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorDownLine.

process CSI n E corresponding to CNL – Cursor Next Line

Parameters
count:int

line count

Annotations
@Override
Exceptions
IOException:
IOException
processCursorLeftback to summary
protected void processCursorLeft(int count) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorLeft.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorLeft.

process CSI n D corresponding to CUB – Cursor Back

Parameters
count:int

count

Annotations
@Override
Exceptions
IOException:
IOException
processCursorRightback to summary
protected void processCursorRight(int count) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorRight.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorRight.

process CSI n C corresponding to CUF – Cursor Forward

Parameters
count:int

count

Annotations
@Override
Exceptions
IOException:
IOException
processCursorToback to summary
protected void processCursorTo(int row, int col) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorTo.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorTo.

process CSI n ; m H corresponding to CUP – Cursor Position or CSI n ; m f corresponding to HVP – Horizontal and Vertical Position

Parameters
row:int

row

col:int

col

Annotations
@Override
Exceptions
IOException:
IOException
processCursorToColumnback to summary
protected void processCursorToColumn(int x) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorToColumn.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorToColumn.

process CSI n G corresponding to CHA – Cursor Horizontal Absolute

Parameters
x:int

the column

Annotations
@Override
Exceptions
IOException:
IOException
processCursorUpback to summary
protected void processCursorUp(int count) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorUp.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorUp.

process CSI n A corresponding to CUU – Cursor Up

Parameters
count:int

count

Annotations
@Override
Exceptions
IOException:
IOException
processCursorUpLineback to summary
protected void processCursorUpLine(int count) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processCursorUpLine.

Doc from org.fusesource.jansi.io.AnsiProcessor.processCursorUpLine.

process CSI n F corresponding to CPL – Cursor Previous Line

Parameters
count:int

line count

Annotations
@Override
Exceptions
IOException:
IOException
processDefaultBackgroundColorback to summary
protected void processDefaultBackgroundColor() throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processDefaultBackgroundColor.

Doc from org.fusesource.jansi.io.AnsiProcessor.processDefaultBackgroundColor.

process SGR 49 corresponding to Default background color

Annotations
@Override
Exceptions
IOException:
IOException
processDefaultTextColorback to summary
protected void processDefaultTextColor() throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processDefaultTextColor.

Doc from org.fusesource.jansi.io.AnsiProcessor.processDefaultTextColor.

process SGR 39 corresponding to Default text color (foreground)

Annotations
@Override
Exceptions
IOException:
IOException
processDeleteLineback to summary
protected void processDeleteLine(int optionInt) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processDeleteLine.

Doc from org.fusesource.jansi.io.AnsiProcessor.processDeleteLine.

Process CSI M ANSI code, corresponding to DL – Delete Line

Parameters
optionInt:int

option

Annotations
@Override
Exceptions
IOException:
IOException
processEraseLineback to summary
protected void processEraseLine(int eraseOption) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processEraseLine.

Doc from org.fusesource.jansi.io.AnsiProcessor.processEraseLine.

Process CSI n K ANSI code, corresponding to ED – Erase in Line

Parameters
eraseOption:int

eraseOption

Annotations
@Override
Exceptions
IOException:
IOException
processEraseScreenback to summary
protected void processEraseScreen(int eraseOption) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processEraseScreen.

Doc from org.fusesource.jansi.io.AnsiProcessor.processEraseScreen.

Process CSI n J ANSI code, corresponding to ED – Erase in Display

Parameters
eraseOption:int

eraseOption

Annotations
@Override
Exceptions
IOException:
IOException
processInsertLineback to summary
protected void processInsertLine(int optionInt) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processInsertLine.

Doc from org.fusesource.jansi.io.AnsiProcessor.processInsertLine.

Process CSI L ANSI code, corresponding to IL – Insert Line

Parameters
optionInt:int

option

Annotations
@Override
Exceptions
IOException:
IOException
processRestoreCursorPositionback to summary
protected void processRestoreCursorPosition() throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processRestoreCursorPosition.

Doc from org.fusesource.jansi.io.AnsiProcessor.processRestoreCursorPosition.

Process CSI u ANSI code, corresponding to RCP – Restore Cursor Position

Annotations
@Override
Exceptions
IOException:
IOException
processSaveCursorPositionback to summary
protected void processSaveCursorPosition() throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSaveCursorPosition.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSaveCursorPosition.

Process CSI s ANSI code, corresponding to SCP – Save Cursor Position

Annotations
@Override
Exceptions
IOException:
IOException
processSetAttributeback to summary
protected void processSetAttribute(int attribute) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetAttribute.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSetAttribute.

process SGR other than 0 (reset), 30-39 (foreground), 40-49 (background), 90-97 (foreground high intensity) or 100-107 (background high intensity)

Parameters
attribute:int

attribute

Annotations
@Override
Exceptions
IOException:
IOException
processSetBackgroundColorback to summary
protected void processSetBackgroundColor(int color, boolean bright) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColor.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColor.

process SGR 40-47 or SGR 100-107 corresponding to Set background color either in normal mode or high intensity.

Parameters
color:int

the background color

bright:boolean

is high intensity?

Annotations
@Override
Exceptions
IOException:
IOException
processSetBackgroundColorExtback to summary
protected void processSetBackgroundColorExt(int paletteIndex) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColorExt.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColorExt.

process SGR 48 corresponding to extended set background color with a palette of 255 colors.

Parameters
paletteIndex:int

the background color in the palette

Annotations
@Override
Exceptions
IOException:
IOException
processSetBackgroundColorExtback to summary
protected void processSetBackgroundColorExt(int r, int g, int b) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColorExt.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSetBackgroundColorExt.

process SGR 48 corresponding to extended set background color with a 24 bits RGB definition of the color.

Parameters
r:int

red

g:int

green

b:int

blue

Annotations
@Override
Exceptions
IOException:
IOException
processSetForegroundColorback to summary
protected void processSetForegroundColor(int color, boolean bright) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColor.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColor.

process SGR 30-37 or SGR 90-97 corresponding to Set text color (foreground) either in normal mode or high intensity.

Parameters
color:int

the text color

bright:boolean

is high intensity?

Annotations
@Override
Exceptions
IOException:
IOException
processSetForegroundColorExtback to summary
protected void processSetForegroundColorExt(int paletteIndex) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColorExt.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColorExt.

process SGR 38 corresponding to extended set text color (foreground) with a palette of 255 colors.

Parameters
paletteIndex:int

the text color in the palette

Annotations
@Override
Exceptions
IOException:
IOException
processSetForegroundColorExtback to summary
protected void processSetForegroundColorExt(int r, int g, int b) throws IOException

Overrides org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColorExt.

Doc from org.fusesource.jansi.io.AnsiProcessor.processSetForegroundColorExt.

process SGR 38 corresponding to extended set text color (foreground) with a 24 bits RGB definition of the color.

Parameters
r:int

red

g:int

green

b:int

blue

Annotations
@Override
Exceptions
IOException:
IOException