Class JnaWinSysTerminal

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable, Terminal

    public class JnaWinSysTerminal
    extends AbstractWindowsTerminal<com.sun.jna.Pointer>
    • Field Detail

      • consoleIn

        private static final com.sun.jna.Pointer consoleIn
      • consoleOut

        private static final com.sun.jna.Pointer consoleOut
      • consoleErr

        private static final com.sun.jna.Pointer consoleErr
      • focus

        private char[] focus
      • mouse

        private char[] mouse
      • eventsRead

        private final com.sun.jna.ptr.IntByReference eventsRead
    • Constructor Detail

      • JnaWinSysTerminal

        JnaWinSysTerminal​(java.io.Writer writer,
                          java.lang.String name,
                          java.lang.String type,
                          java.nio.charset.Charset encoding,
                          boolean nativeSignals,
                          Terminal.SignalHandler signalHandler,
                          com.sun.jna.Pointer inConsole,
                          int inConsoleMode,
                          com.sun.jna.Pointer outConsole,
                          int outConsoleMode)
                   throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • createTerminal

        public static JnaWinSysTerminal createTerminal​(java.lang.String name,
                                                       java.lang.String type,
                                                       boolean ansiPassThrough,
                                                       java.nio.charset.Charset encoding,
                                                       boolean nativeSignals,
                                                       Terminal.SignalHandler signalHandler,
                                                       boolean paused,
                                                       TerminalProvider.Stream consoleStream)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • enableVtp

        private static boolean enableVtp​(com.sun.jna.Pointer console,
                                         int outMode)
      • getSize

        public Size getSize()
        Description copied from interface: Terminal
        Retrieve the size of the visible window
        Returns:
        the visible terminal size
        See Also:
        Terminal.getBufferSize()
      • getBufferSize

        public Size getBufferSize()
        Description copied from interface: Terminal
        Retrieve the size of the window buffer. Some terminals can be configured to have a buffer size larger than the visible window size and provide scroll bars. In such cases, this method should attempt to return the size of the whole buffer. The getBufferSize() method can be used to avoid wrapping when using the terminal in a line editing mode, while the Terminal.getSize() method should be used when using full screen mode.
        Returns:
        the terminal buffer size
        See Also:
        Terminal.getSize()
      • processConsoleInput

        protected boolean processConsoleInput()
                                       throws java.io.IOException
        Description copied from class: AbstractWindowsTerminal
        Read a single input event from the input buffer and process it.
        Specified by:
        processConsoleInput in class AbstractWindowsTerminal<com.sun.jna.Pointer>
        Returns:
        true if new input was generated from the event
        Throws:
        java.io.IOException - if anything wrong happens
      • processKeyEvent

        private void processKeyEvent​(Kernel32.KEY_EVENT_RECORD keyEvent)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • processFocusEvent

        private void processFocusEvent​(boolean hasFocus)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • processMouseEvent

        private void processMouseEvent​(Kernel32.MOUSE_EVENT_RECORD mouseEvent)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • readConsoleInput

        private Kernel32.INPUT_RECORD readConsoleInput​(int dwMilliseconds)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getCursorPosition

        public Cursor getCursorPosition​(java.util.function.IntConsumer discarded)
        Description copied from interface: Terminal
        Query the terminal to report the cursor position. As the response is read from the input stream, some characters may be read before the cursor position is actually read. Those characters can be given back using org.jline.keymap.BindingReader#runMacro(String)
        Specified by:
        getCursorPosition in interface Terminal
        Overrides:
        getCursorPosition in class AbstractTerminal
        Parameters:
        discarded - a consumer receiving discarded characters
        Returns:
        null if cursor position reporting is not supported or a valid cursor position