Class WinSysTerminal

java.lang.Object
org.aesh.terminal.tty.impl.AbstractTerminal
org.aesh.terminal.tty.impl.WinSysTerminal
All Implemented Interfaces:
Closeable, AutoCloseable, Terminal

public class WinSysTerminal extends AbstractTerminal
Windows system terminal implementation using native console API.
  • Field Details

    • ENABLE_PROCESSED_INPUT

      protected static final int ENABLE_PROCESSED_INPUT
      Enable processed input mode.
      See Also:
    • ENABLE_LINE_INPUT

      protected static final int ENABLE_LINE_INPUT
      Enable line input mode.
      See Also:
    • ENABLE_ECHO_INPUT

      protected static final int ENABLE_ECHO_INPUT
      Enable echo input mode.
      See Also:
    • ENABLE_WINDOW_INPUT

      protected static final int ENABLE_WINDOW_INPUT
      Enable window input mode.
      See Also:
    • ENABLE_MOUSE_INPUT

      protected static final int ENABLE_MOUSE_INPUT
      Enable mouse input mode.
      See Also:
    • ENABLE_INSERT_MODE

      protected static final int ENABLE_INSERT_MODE
      Enable insert mode.
      See Also:
    • ENABLE_QUICK_EDIT_MODE

      protected static final int ENABLE_QUICK_EDIT_MODE
      Enable quick edit mode.
      See Also:
    • slaveInputPipe

      protected final OutputStream slaveInputPipe
      Slave input pipe.
    • input

      protected final InputStream input
      Terminal input stream.
    • output

      protected final OutputStream output
      Terminal output stream.
    • writer

      protected final PrintWriter writer
      Print writer for output.
    • nativeHandlers

      protected final Map<Signal,Object> nativeHandlers
      Map of native signal handlers.
    • closer

      protected final ShutdownHooks.Task closer
      Shutdown hook task for cleanup.
    • attributes

      protected final Attributes attributes
      Terminal attributes.
    • pump

      protected final Thread pump
      Input pump thread.
  • Constructor Details

    • WinSysTerminal

      public WinSysTerminal(String name, boolean nativeSignals) throws IOException
      Create a new Windows system terminal with the specified name.
      Parameters:
      name - the terminal name
      nativeSignals - 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 name
      nativeSignals - whether to use native signal handling
      signalHandler - 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

      public Size 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

      public Consumer<int[]> getCodePointConsumer()
    • handleDefaultSignal

      protected void handleDefaultSignal(Signal signal)
      Description copied from class: AbstractTerminal
      Handles the default behavior for a signal when no custom handler is registered. Subclasses can override this method to provide default signal handling behavior.
      Overrides:
      handleDefaultSignal in class AbstractTerminal
      Parameters:
      signal - the signal to handle
    • getConsoleEncoding

      protected String getConsoleEncoding()
      Get the console encoding based on the console output code page.
      Returns:
      the charset name, or null if not supported
    • writer

      public PrintWriter writer()
      Get the print writer for output.
      Returns:
      the print writer
    • input

      public InputStream input()
    • output

      public OutputStream output()
    • getAttributes

      public Attributes getAttributes()
    • setAttributes

      public void setAttributes(Attributes attr)
      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

      public void setSize(Size size)
      Set the terminal size. Not supported on Windows.
      Parameters:
      size - the size to set
      Throws:
      UnsupportedOperationException - always
    • close

      public void close() throws IOException
      Throws:
      IOException
    • getEscapeSequence

      protected String getEscapeSequence(short keyCode)
      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

      protected String getSequence(Capability cap)
      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.