APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.org.jline.terminal.impl

public abstract Class AbstractWindowsTerminal<Console>

extends AbstractTerminal
Class Inheritance
Known Direct Subclasses
jdk.internal.org.jline.terminal.impl.ffm.NativeWinSysTerminal
Imports
java.io.IOException, .InputStream, .OutputStream, .PrintWriter, .Writer, java.nio.charset.Charset, java.util.HashMap, .Map, java.util.function.Function, jdk.internal.org.jline.terminal.Attributes, .Size, jdk.internal.org.jline.terminal.spi.SystemStream, .TerminalProvider, jdk.internal.org.jline.utils.Curses, .InfoCmp, .Log, .NonBlocking, .NonBlockingInputStream, .NonBlockingPumpReader, .NonBlockingReader, .ShutdownHooks, .Signals, .WriterOutputStream

The AbstractWindowsTerminal is used as the base class for windows terminal. Due to windows limitations, mostly the missing support for ansi sequences, the only way to create a correct terminal is to use the windows api to set character attributes, move the cursor, erasing, etc... UTF-8 support is also lacking in windows and the code page supposed to emulate UTF-8 is a bit broken. In order to work around this broken code page, windows api WriteConsoleW is used directly. This means that the writer() becomes the primary output, while the output() is bridged to the writer() using a WriterOutputStream wrapper.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
protected final Attributes
pack-priv static final int
protected final ShutdownHooks.Task
private volatile boolean
pack-priv static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
public static final int
protected static final int
protected boolean
protected final Console
protected final InputStream
pack-priv static final int
pack-priv static final int
protected final Object
protected final Map<Terminal.Signal, Object>
pack-priv static final int
protected final int
protected final int
protected final Console
protected final OutputStream
protected boolean
private final TerminalProvider
protected Thread
protected final NonBlockingReader
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
protected boolean
protected final Writer
private final SystemStream
protected Terminal.MouseTracking
public static final String
public static final String
public static final String
public static final String
private static final int
protected final PrintWriter
Inherited from jdk.internal.org.jline.terminal.impl.AbstractTerminal:
boolsencodinghandlersintsnameonClosepalettestatusstringstype

Constructor Summary

AccessConstructor and Description
public
AbstractWindowsTerminal(TerminalProvider provider, SystemStream systemStream, Writer writer, String name, String type, Charset encoding, boolean nativeSignals, Terminal.SignalHandler signalHandler, Console inConsole, int inConsoleMode, Console outConsole, int outConsoleMode, Function<InputStream, InputStream> inputStreamWrapper)

Method Summary

Modifier and TypeMethod and Description
public boolean
protected int
ctrl(char key)

protected void
public Attributes
getAttributes()

Implements jdk.internal.org.jline.terminal.Terminal.getAttributes.

Returns the terminal attributes.

protected abstract int
getConsoleMode(Console console)

protected String
getEscapeSequence(short keyCode, int keyState)

public TerminalProvider
getProvider()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getProvider.

Returns the TerminalProvider that created this terminal or null if the terminal was created with no provider.

protected String
public SystemStream
getSystemStream()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getSystemStream.

The underlying system stream, may be SystemStream#Output, SystemStream#Error, or null if this terminal is not bound to a system stream.

public Terminal.SignalHandler
public boolean
public InputStream
input()

Implements jdk.internal.org.jline.terminal.Terminal.input.

Retrieve the input stream for this terminal.

public OutputStream
output()

Implements jdk.internal.org.jline.terminal.Terminal.output.

Retrieve the output stream for this terminal.

public void
public void
pause(boolean wait)

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.pause.

Implements jdk.internal.org.jline.terminal.Terminal.pause.

Stop reading the input stream and optionally wait for the underlying threads to finish.

public boolean
paused()

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.paused.

Implements jdk.internal.org.jline.terminal.Terminal.paused.

Check whether the terminal is currently reading the input stream or not.

protected abstract boolean

Returns:

true if new input was generated from the event
processConsoleInput
()

Read a single input event from the input buffer and process it.

public void
protected void
processKeyEvent(final boolean isKeyDown, final short virtualKeyCode, char ch, final int controlKeyState)

protected void
pump()

public NonBlockingReader
reader()

Implements jdk.internal.org.jline.terminal.Terminal.reader.

Retrieve the Reader for this terminal.

public void
public void
protected abstract void
setConsoleMode(Console console, int mode)

public void
public boolean
public boolean
protected void
public PrintWriter
writer()

Implements jdk.internal.org.jline.terminal.Terminal.writer.

Retrieve the Writer for this terminal.

Inherited from jdk.internal.org.jline.terminal.impl.AbstractTerminal:
checkInterruptedcloseechoechoechoSignalencodingenterRawModeflushgetBooleanCapabilitygetCursorPositiongetKindgetNamegetNumericCapabilitygetPalettegetStatusgetStatusgetStringCapabilitygetTypehasMouseSupportparseInfoCmpputsraisereadMouseEventreadMouseEventsetOnClosetoString

Field Detail

ALT_FLAGback to summary
pack-priv static final int ALT_FLAG
attributesback to summary
protected final Attributes attributes
CAPSLOCK_ONback to summary
pack-priv static final int CAPSLOCK_ON
closerback to summary
protected final ShutdownHooks.Task closer
closingback to summary
private volatile boolean closing
CTRL_FLAGback to summary
pack-priv static final int CTRL_FLAG
ENABLE_ECHO_INPUTback to summary
protected static final int ENABLE_ECHO_INPUT
ENABLE_EXTENDED_FLAGSback to summary
protected static final int ENABLE_EXTENDED_FLAGS
ENABLE_INSERT_MODEback to summary
protected static final int ENABLE_INSERT_MODE
ENABLE_LINE_INPUTback to summary
protected static final int ENABLE_LINE_INPUT
ENABLE_MOUSE_INPUTback to summary
protected static final int ENABLE_MOUSE_INPUT
ENABLE_PROCESSED_INPUTback to summary
protected static final int ENABLE_PROCESSED_INPUT
ENABLE_QUICK_EDIT_MODEback to summary
protected static final int ENABLE_QUICK_EDIT_MODE
ENABLE_VIRTUAL_TERMINAL_PROCESSINGback to summary
public static final int ENABLE_VIRTUAL_TERMINAL_PROCESSING
ENABLE_WINDOW_INPUTback to summary
protected static final int ENABLE_WINDOW_INPUT
focusTrackingback to summary
protected boolean focusTracking
inConsoleback to summary
protected final Console inConsole
inputback to summary
protected final InputStream input
LEFT_ALT_PRESSEDback to summary
pack-priv static final int LEFT_ALT_PRESSED
LEFT_CTRL_PRESSEDback to summary
pack-priv static final int LEFT_CTRL_PRESSED
lockback to summary
protected final Object lock
nativeHandlersback to summary
protected final Map<Terminal.Signal, Object> nativeHandlers
NUMLOCK_ONback to summary
pack-priv static final int NUMLOCK_ON
originalInConsoleModeback to summary
protected final int originalInConsoleMode
originalOutConsoleModeback to summary
protected final int originalOutConsoleMode
outConsoleback to summary
protected final Console outConsole
outputback to summary
protected final OutputStream output
pausedback to summary
protected boolean paused
providerback to summary
private final TerminalProvider provider
pumpback to summary
protected Thread pump
readerback to summary
protected final NonBlockingReader reader
RIGHT_ALT_PRESSEDback to summary
pack-priv static final int RIGHT_ALT_PRESSED
RIGHT_CTRL_PRESSEDback to summary
pack-priv static final int RIGHT_CTRL_PRESSED
SCROLLLOCK_ONback to summary
pack-priv static final int SCROLLLOCK_ON
SHIFT_FLAGback to summary
pack-priv static final int SHIFT_FLAG
SHIFT_PRESSEDback to summary
pack-priv static final int SHIFT_PRESSED
skipNextLfback to summary
protected boolean skipNextLf
slaveInputPipeback to summary
protected final Writer slaveInputPipe
systemStreamback to summary
private final SystemStream systemStream
trackingback to summary
protected Terminal.MouseTracking tracking
TYPE_WINDOWSback to summary
public static final String TYPE_WINDOWS
TYPE_WINDOWS_256_COLORback to summary
public static final String TYPE_WINDOWS_256_COLOR
TYPE_WINDOWS_CONEMUback to summary
public static final String TYPE_WINDOWS_CONEMU
TYPE_WINDOWS_VTPback to summary
public static final String TYPE_WINDOWS_VTP
UTF8_CODE_PAGEback to summary
private static final int UTF8_CODE_PAGE
writerback to summary
protected final PrintWriter writer

Constructor Detail

AbstractWindowsTerminalback to summary
public AbstractWindowsTerminal(TerminalProvider provider, SystemStream systemStream, Writer writer, String name, String type, Charset encoding, boolean nativeSignals, Terminal.SignalHandler signalHandler, Console inConsole, int inConsoleMode, Console outConsole, int outConsoleMode, Function<InputStream, InputStream> inputStreamWrapper) throws IOException
Annotations
@SuppressWarnings:this-escape

Method Detail

canPauseResumeback to summary
public boolean canPauseResume()

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.canPauseResume.

Implements jdk.internal.org.jline.terminal.Terminal.canPauseResume.

Doc from jdk.internal.org.jline.terminal.Terminal.canPauseResume.

Whether this terminal supports pause() and resume() calls.

Annotations
@Override
ctrlback to summary
protected int ctrl(char key)
doCloseback to summary
protected void doClose() throws IOException

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.doClose.

getAttributesback to summary
public Attributes getAttributes()

Implements jdk.internal.org.jline.terminal.Terminal.getAttributes.

Doc from jdk.internal.org.jline.terminal.Terminal.getAttributes.

Returns the terminal attributes. The returned object can be safely modified further used in a call to setAttributes(Attributes).

getConsoleModeback to summary
protected abstract int getConsoleMode(Console console)
getEscapeSequenceback to summary
protected String getEscapeSequence(short keyCode, int keyState)
getProviderback to summary
public TerminalProvider getProvider()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getProvider.

Doc from jdk.internal.org.jline.terminal.spi.TerminalExt.getProvider.

Returns the TerminalProvider that created this terminal or null if the terminal was created with no provider.

Annotations
@Override
getRawSequenceback to summary
protected String getRawSequence(InfoCmp.Capability cap)
getSystemStreamback to summary
public SystemStream getSystemStream()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getSystemStream.

Doc from jdk.internal.org.jline.terminal.spi.TerminalExt.getSystemStream.

The underlying system stream, may be SystemStream#Output, SystemStream#Error, or null if this terminal is not bound to a system stream.

Annotations
@Override
handleback to summary
public Terminal.SignalHandler handle(Terminal.Signal signal, Terminal.SignalHandler handler)

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.handle.

Implements jdk.internal.org.jline.terminal.Terminal.handle.

Doc from jdk.internal.org.jline.terminal.Terminal.handle.

Registers a handler for the given Signal.

Note that the JVM does not easily allow catching the Signal#QUIT signal, which causes a thread dump to be displayed. This signal is mainly used when connecting through an SSH socket to a virtual terminal.

Annotations
@Override
hasFocusSupportback to summary
public boolean hasFocusSupport()

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.hasFocusSupport.

Implements jdk.internal.org.jline.terminal.Terminal.hasFocusSupport.

Doc from jdk.internal.org.jline.terminal.Terminal.hasFocusSupport.

Returns true if the terminal has support for focus tracking.

Annotations
@Override
inputback to summary
public InputStream input()

Implements jdk.internal.org.jline.terminal.Terminal.input.

Doc from jdk.internal.org.jline.terminal.Terminal.input.

Retrieve the input stream for this terminal. In some rare cases, there may be a need to access the terminal input stream directly. In the usual cases, use the reader() instead.

Annotations
@Override
outputback to summary
public OutputStream output()

Implements jdk.internal.org.jline.terminal.Terminal.output.

Doc from jdk.internal.org.jline.terminal.Terminal.output.

Retrieve the output stream for this terminal. In some rare cases, there may be a need to access the terminal output stream directly. In the usual cases, use the writer() instead.

Annotations
@Override
pauseback to summary
public void pause()

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.pause.

Implements jdk.internal.org.jline.terminal.Terminal.pause.

Doc from jdk.internal.org.jline.terminal.Terminal.pause.

Stop reading the input stream.

Annotations
@Override
pauseback to summary
public void pause(boolean wait) throws InterruptedException

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.pause.

Implements jdk.internal.org.jline.terminal.Terminal.pause.

Doc from jdk.internal.org.jline.terminal.Terminal.pause.

Stop reading the input stream and optionally wait for the underlying threads to finish.

Annotations
@Override
Exceptions
InterruptedException:
if the call has been interrupted
pausedback to summary
public boolean paused()

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.paused.

Implements jdk.internal.org.jline.terminal.Terminal.paused.

Doc from jdk.internal.org.jline.terminal.Terminal.paused.

Check whether the terminal is currently reading the input stream or not. In order to process signal as quickly as possible, the terminal need to read the input stream and buffer it internally so that it can detect specific characters in the input stream (Ctrl+C, Ctrl+D, etc...) and raise the appropriate signals. However, there are some cases where this processing should be disabled, for example when handing the terminal control to a subprocess.

Annotations
@Override
processConsoleInputback to summary
protected abstract boolean processConsoleInput() throws IOException

Read a single input event from the input buffer and process it.

Returns:boolean

true if new input was generated from the event

Exceptions
IOException:
if anything wrong happens
processInputCharback to summary
public void processInputChar(char c) throws IOException
processKeyEventback to summary
protected void processKeyEvent(final boolean isKeyDown, final short virtualKeyCode, char ch, final int controlKeyState) throws IOException
pumpback to summary
protected void pump()
readerback to summary
public NonBlockingReader reader()

Implements jdk.internal.org.jline.terminal.Terminal.reader.

Doc from jdk.internal.org.jline.terminal.Terminal.reader.

Retrieve the Reader for this terminal. This is the standard way to read input from this terminal. The reader is non blocking.

resumeback to summary
public void resume()

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.resume.

Implements jdk.internal.org.jline.terminal.Terminal.resume.

Doc from jdk.internal.org.jline.terminal.Terminal.resume.

Resume reading the input stream.

Annotations
@Override
setAttributesback to summary
public void setAttributes(Attributes attr)

Implements jdk.internal.org.jline.terminal.Terminal.setAttributes.

Doc from jdk.internal.org.jline.terminal.Terminal.setAttributes.

Set the terminal attributes. The terminal will perform a copy of the given attributes.

setConsoleModeback to summary
protected abstract void setConsoleMode(Console console, int mode)
setSizeback to summary
public void setSize(Size size)

Implements jdk.internal.org.jline.terminal.Terminal.setSize.

trackFocusback to summary
public boolean trackFocus(boolean tracking)

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.trackFocus.

Implements jdk.internal.org.jline.terminal.Terminal.trackFocus.

Doc from jdk.internal.org.jline.terminal.Terminal.trackFocus.

Enable or disable focus tracking mode. When focus tracking has been activated, each time the terminal grabs the focus, the string "\33[I" will be sent to the input stream and each time the focus is lost, the string "\33[O" will be sent to the input stream.

Annotations
@Override
trackMouseback to summary
public boolean trackMouse(Terminal.MouseTracking tracking)

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.trackMouse.

Implements jdk.internal.org.jline.terminal.Terminal.trackMouse.

Doc from jdk.internal.org.jline.terminal.Terminal.trackMouse.

Change the mouse tracking mouse. To start mouse tracking, this method must be called with a valid mouse tracking mode. Mouse events will be reported by writing the Capability#key_mouse to the input stream. When this character sequence is detected, the readMouseEvent() method can be called to actually read the corresponding mouse event.

Annotations
@Override
updateConsoleModeback to summary
protected void updateConsoleMode()
writerback to summary
public PrintWriter writer()

Implements jdk.internal.org.jline.terminal.Terminal.writer.

Doc from jdk.internal.org.jline.terminal.Terminal.writer.

Retrieve the Writer for this terminal. This is the standard way to write to this terminal.