Package org.fusesource.jansi.io
Class AnsiOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- org.fusesource.jansi.io.AnsiOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class AnsiOutputStream extends java.io.FilterOutputStream
A ANSI print stream extracts ANSI escape codes written to an output stream and calls correspondingAnsiProcessor.process*
methods. This particular class is not synchronized for improved performances.For more information about ANSI escape codes, see Wikipedia article
- Since:
- 1.0
- See Also:
AnsiProcessor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AnsiOutputStream.IoRunnable
-
Field Summary
Fields Modifier and Type Field Description private AnsiProcessor
ap
private static int
BEL
private byte[]
buffer
private AnsiColors
colors
private java.nio.charset.Charset
cs
private static int
FIRST_ESC_CHAR
private AnsiOutputStream.IoRunnable
installer
private static int
LOOKING_FOR_CHARSET
private static int
LOOKING_FOR_FIRST_ESC_CHAR
private static int
LOOKING_FOR_INT_ARG_END
private static int
LOOKING_FOR_NEXT_ARG
private static int
LOOKING_FOR_OSC_COMMAND
private static int
LOOKING_FOR_OSC_COMMAND_END
private static int
LOOKING_FOR_OSC_PARAM
private static int
LOOKING_FOR_SECOND_ESC_CHAR
private static int
LOOKING_FOR_ST
private static int
LOOKING_FOR_STR_ARG_END
private static int
MAX_ESCAPE_SEQUENCE_LENGTH
private AnsiMode
mode
private java.util.ArrayList<java.lang.Object>
options
private int
pos
private AnsiProcessor
processor
static byte[]
RESET_CODE
private boolean
resetAtUninstall
private static int
SECOND_CHARSET0_CHAR
private static int
SECOND_CHARSET1_CHAR
private static int
SECOND_ESC_CHAR
private static int
SECOND_OSC_CHAR
private static int
SECOND_ST_CHAR
private int
startOfValue
private int
state
private AnsiType
type
private AnsiOutputStream.IoRunnable
uninstaller
-
Constructor Summary
Constructors Constructor Description AnsiOutputStream(java.io.OutputStream os, AnsiMode mode, AnsiProcessor processor, AnsiType type, AnsiColors colors, java.nio.charset.Charset cs, AnsiOutputStream.IoRunnable installer, AnsiOutputStream.IoRunnable uninstaller, boolean resetAtUninstall)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
AnsiColors
getColors()
AnsiMode
getMode()
AnsiType
getType()
void
install()
boolean
isResetAtUninstall()
private void
processCharsetSelect()
private void
processEscapeCommand(int data)
private void
processOperatingSystemCommand()
private void
reset(boolean skipBuffer)
Resets all state to continue with regular parsingvoid
setMode(AnsiMode mode)
void
setResetAtUninstall(boolean resetAtUninstall)
void
uninstall()
void
write(int data)
-
-
-
Field Detail
-
RESET_CODE
public static final byte[] RESET_CODE
-
LOOKING_FOR_FIRST_ESC_CHAR
private static final int LOOKING_FOR_FIRST_ESC_CHAR
- See Also:
- Constant Field Values
-
LOOKING_FOR_SECOND_ESC_CHAR
private static final int LOOKING_FOR_SECOND_ESC_CHAR
- See Also:
- Constant Field Values
-
LOOKING_FOR_NEXT_ARG
private static final int LOOKING_FOR_NEXT_ARG
- See Also:
- Constant Field Values
-
LOOKING_FOR_STR_ARG_END
private static final int LOOKING_FOR_STR_ARG_END
- See Also:
- Constant Field Values
-
LOOKING_FOR_INT_ARG_END
private static final int LOOKING_FOR_INT_ARG_END
- See Also:
- Constant Field Values
-
LOOKING_FOR_OSC_COMMAND
private static final int LOOKING_FOR_OSC_COMMAND
- See Also:
- Constant Field Values
-
LOOKING_FOR_OSC_COMMAND_END
private static final int LOOKING_FOR_OSC_COMMAND_END
- See Also:
- Constant Field Values
-
LOOKING_FOR_OSC_PARAM
private static final int LOOKING_FOR_OSC_PARAM
- See Also:
- Constant Field Values
-
LOOKING_FOR_ST
private static final int LOOKING_FOR_ST
- See Also:
- Constant Field Values
-
LOOKING_FOR_CHARSET
private static final int LOOKING_FOR_CHARSET
- See Also:
- Constant Field Values
-
FIRST_ESC_CHAR
private static final int FIRST_ESC_CHAR
- See Also:
- Constant Field Values
-
SECOND_ESC_CHAR
private static final int SECOND_ESC_CHAR
- See Also:
- Constant Field Values
-
SECOND_OSC_CHAR
private static final int SECOND_OSC_CHAR
- See Also:
- Constant Field Values
-
BEL
private static final int BEL
- See Also:
- Constant Field Values
-
SECOND_ST_CHAR
private static final int SECOND_ST_CHAR
- See Also:
- Constant Field Values
-
SECOND_CHARSET0_CHAR
private static final int SECOND_CHARSET0_CHAR
- See Also:
- Constant Field Values
-
SECOND_CHARSET1_CHAR
private static final int SECOND_CHARSET1_CHAR
- See Also:
- Constant Field Values
-
ap
private AnsiProcessor ap
-
MAX_ESCAPE_SEQUENCE_LENGTH
private static final int MAX_ESCAPE_SEQUENCE_LENGTH
- See Also:
- Constant Field Values
-
buffer
private final byte[] buffer
-
pos
private int pos
-
startOfValue
private int startOfValue
-
options
private final java.util.ArrayList<java.lang.Object> options
-
state
private int state
-
cs
private final java.nio.charset.Charset cs
-
processor
private final AnsiProcessor processor
-
type
private final AnsiType type
-
colors
private final AnsiColors colors
-
installer
private final AnsiOutputStream.IoRunnable installer
-
uninstaller
private final AnsiOutputStream.IoRunnable uninstaller
-
mode
private AnsiMode mode
-
resetAtUninstall
private boolean resetAtUninstall
-
-
Constructor Detail
-
AnsiOutputStream
public AnsiOutputStream(java.io.OutputStream os, AnsiMode mode, AnsiProcessor processor, AnsiType type, AnsiColors colors, java.nio.charset.Charset cs, AnsiOutputStream.IoRunnable installer, AnsiOutputStream.IoRunnable uninstaller, boolean resetAtUninstall)
-
-
Method Detail
-
getType
public AnsiType getType()
-
getColors
public AnsiColors getColors()
-
getMode
public AnsiMode getMode()
-
setMode
public void setMode(AnsiMode mode)
-
isResetAtUninstall
public boolean isResetAtUninstall()
-
setResetAtUninstall
public void setResetAtUninstall(boolean resetAtUninstall)
-
write
public void write(int data) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
processCharsetSelect
private void processCharsetSelect() throws java.io.IOException
- Throws:
java.io.IOException
-
processOperatingSystemCommand
private void processOperatingSystemCommand() throws java.io.IOException
- Throws:
java.io.IOException
-
processEscapeCommand
private void processEscapeCommand(int data) throws java.io.IOException
- Throws:
java.io.IOException
-
reset
private void reset(boolean skipBuffer) throws java.io.IOException
Resets all state to continue with regular parsing- Parameters:
skipBuffer
- if current buffer should be skipped or written to out- Throws:
java.io.IOException
-
install
public void install() throws java.io.IOException
- Throws:
java.io.IOException
-
uninstall
public void uninstall() throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
-