Package org.aesh.terminal.tty.impl
Class WinSysTerminal
java.lang.Object
org.aesh.terminal.tty.impl.AbstractTerminal
org.aesh.terminal.tty.impl.WinSysTerminal
- All Implemented Interfaces:
Closeable,AutoCloseable,Terminal
Windows system terminal implementation using native console API.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.aesh.terminal.Terminal
Terminal.SignalHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AttributesTerminal attributes.protected final ShutdownHooks.TaskShutdown hook task for cleanup.protected static final intEnable echo input mode.protected static final intEnable insert mode.protected static final intEnable line input mode.protected static final intEnable mouse input mode.protected static final intEnable processed input mode.protected static final intEnable quick edit mode.protected static final intEnable window input mode.protected final InputStreamTerminal input stream.Map of native signal handlers.protected final OutputStreamTerminal output stream.protected final ThreadInput pump thread.protected final OutputStreamSlave input pipe.protected final PrintWriterPrint writer for output. -
Constructor Summary
ConstructorsConstructorDescriptionWinSysTerminal(String name, boolean nativeSignals) Create a new Windows system terminal with the specified name.WinSysTerminal(String name, boolean nativeSignals, Terminal.SignalHandler signalHandler) Create a new Windows system terminal with custom signal handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected intctrl(char key) Convert a character to its control code equivalent.Consumer<int[]> protected StringGet the console encoding based on the console output code page.protected intGet the current console mode.protected intGet the console output code page.protected StringgetEscapeSequence(short keyCode) Get the escape sequence for a Windows virtual key code.protected StringgetSequence(Capability cap) Get the terminal sequence for a capability.getSize()protected voidhandleDefaultSignal(Signal signal) Handles the default behavior for a signal when no custom handler is registered.input()static booleanCheck if virtual terminal mode is supported.output()protected voidpump()Pump thread that reads console input and processes it.protected byte[]Read console input from the Windows console.voidsetAttributes(Attributes attr) Set terminal attributes.protected voidsetConsoleMode(int mode) Set the console mode.voidSet the terminal size.writer()Get the print writer for output.Methods inherited from class org.aesh.terminal.tty.impl.AbstractTerminal
device, echo, echo, echoSignal, getName, getType, handle, raise
-
Field Details
-
ENABLE_PROCESSED_INPUT
protected static final int ENABLE_PROCESSED_INPUTEnable processed input mode.- See Also:
-
ENABLE_LINE_INPUT
protected static final int ENABLE_LINE_INPUTEnable line input mode.- See Also:
-
ENABLE_ECHO_INPUT
protected static final int ENABLE_ECHO_INPUTEnable echo input mode.- See Also:
-
ENABLE_WINDOW_INPUT
protected static final int ENABLE_WINDOW_INPUTEnable window input mode.- See Also:
-
ENABLE_MOUSE_INPUT
protected static final int ENABLE_MOUSE_INPUTEnable mouse input mode.- See Also:
-
ENABLE_INSERT_MODE
protected static final int ENABLE_INSERT_MODEEnable insert mode.- See Also:
-
ENABLE_QUICK_EDIT_MODE
protected static final int ENABLE_QUICK_EDIT_MODEEnable quick edit mode.- See Also:
-
slaveInputPipe
Slave input pipe. -
input
Terminal input stream. -
output
Terminal output stream. -
writer
Print writer for output. -
nativeHandlers
Map of native signal handlers. -
closer
Shutdown hook task for cleanup. -
attributes
Terminal attributes. -
pump
Input pump thread.
-
-
Constructor Details
-
WinSysTerminal
Create a new Windows system terminal with the specified name.- Parameters:
name- the terminal namenativeSignals- whether to use native signal handling- Throws:
IOException- if an I/O error occurs
-
WinSysTerminal
public WinSysTerminal(String name, boolean nativeSignals, Terminal.SignalHandler signalHandler) throws IOException Create a new Windows system terminal with custom signal handler.- Parameters:
name- the terminal namenativeSignals- whether to use native signal handlingsignalHandler- the signal handler to use- Throws:
IOException- if an I/O error occurs
-
-
Method Details
-
getConsoleOutputCP
protected int getConsoleOutputCP()Get the console output code page.- Returns:
- the code page number
-
getConsoleMode
protected int getConsoleMode()Get the current console mode.- Returns:
- the console mode flags
-
setConsoleMode
protected void setConsoleMode(int mode) Set the console mode.- Parameters:
mode- the mode flags to set
-
getSize
-
readConsoleInput
protected byte[] readConsoleInput()Read console input from the Windows console.- Returns:
- the input bytes
-
isVTSupported
public static boolean isVTSupported()Check if virtual terminal mode is supported.- Returns:
- true if virtual terminal mode is supported
-
getCodePointConsumer
-
handleDefaultSignal
Description copied from class:AbstractTerminalHandles the default behavior for a signal when no custom handler is registered. Subclasses can override this method to provide default signal handling behavior.- Overrides:
handleDefaultSignalin classAbstractTerminal- Parameters:
signal- the signal to handle
-
getConsoleEncoding
Get the console encoding based on the console output code page.- Returns:
- the charset name, or null if not supported
-
writer
Get the print writer for output.- Returns:
- the print writer
-
input
-
output
-
getAttributes
-
setAttributes
Set terminal attributes.- Parameters:
attr- the attributes to set
-
ctrl
protected int ctrl(char key) Convert a character to its control code equivalent.- Parameters:
key- the character- Returns:
- the control code
-
setSize
Set the terminal size. Not supported on Windows.- Parameters:
size- the size to set- Throws:
UnsupportedOperationException- always
-
close
- Throws:
IOException
-
getEscapeSequence
Get the escape sequence for a Windows virtual key code.- Parameters:
keyCode- the Windows virtual key code- Returns:
- the escape sequence, or null if not mapped
-
getSequence
Get the terminal sequence for a capability.- Parameters:
cap- the capability- Returns:
- the sequence string, or null if not available
-
pump
protected void pump()Pump thread that reads console input and processes it.
-