Class AbstractTerminal

    • Field Detail

      • name

        protected final java.lang.String name
      • type

        protected final java.lang.String type
      • encoding

        protected final java.nio.charset.Charset encoding
      • status

        protected Status status
      • onClose

        protected java.lang.Runnable onClose
      • lastMouseEvent

        private MouseEvent lastMouseEvent
    • Constructor Detail

      • AbstractTerminal

        public AbstractTerminal​(java.lang.String name,
                                java.lang.String type)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • AbstractTerminal

        public AbstractTerminal​(java.lang.String name,
                                java.lang.String type,
                                java.nio.charset.Charset encoding,
                                Terminal.SignalHandler signalHandler)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • setOnClose

        public void setOnClose​(java.lang.Runnable onClose)
      • getStatus

        public Status getStatus()
      • getStatus

        public Status getStatus​(boolean create)
      • close

        public final void close()
                         throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • doClose

        protected void doClose()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • echo

        public boolean echo()
        Specified by:
        echo in interface Terminal
      • echo

        public boolean echo​(boolean echo)
        Specified by:
        echo in interface Terminal
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface Terminal
      • getType

        public java.lang.String getType()
        Specified by:
        getType in interface Terminal
      • getKind

        public java.lang.String getKind()
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in interface Terminal
      • parseInfoCmp

        protected void parseInfoCmp()
      • 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
        Parameters:
        discarded - a consumer receiving discarded characters
        Returns:
        null if cursor position reporting is not supported or a valid cursor position
      • trackMouse

        public boolean trackMouse​(Terminal.MouseTracking tracking)
        Description copied from interface: Terminal
        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 InfoCmp.Capability.key_mouse to the input stream. When this character sequence is detected, the Terminal.readMouseEvent() method can be called to actually read the corresponding mouse event.
        Specified by:
        trackMouse in interface Terminal
        Parameters:
        tracking - the mouse tracking mode
        Returns:
        true if mouse tracking is supported
      • readMouseEvent

        public MouseEvent readMouseEvent​(java.util.function.IntSupplier reader)
        Description copied from interface: Terminal
        Read a MouseEvent from the given input stream.
        Specified by:
        readMouseEvent in interface Terminal
        Parameters:
        reader - the input supplier
        Returns:
        the decoded mouse event
      • hasFocusSupport

        public boolean hasFocusSupport()
        Description copied from interface: Terminal
        Returns true if the terminal has support for focus tracking.
        Specified by:
        hasFocusSupport in interface Terminal
        Returns:
        whether focus tracking is supported by the terminal
        See Also:
        Terminal.trackFocus(boolean)
      • trackFocus

        public boolean trackFocus​(boolean tracking)
        Description copied from interface: Terminal
        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.
        Specified by:
        trackFocus in interface Terminal
        Parameters:
        tracking - whether the focus tracking mode should be enabled or not
        Returns:
        true if focus tracking is supported
      • checkInterrupted

        protected void checkInterrupted()
                                 throws java.io.InterruptedIOException
        Throws:
        java.io.InterruptedIOException
      • pause

        public void pause​(boolean wait)
                   throws java.lang.InterruptedException
        Description copied from interface: Terminal
        Stop reading the input stream and optionally wait for the underlying threads to finish.
        Specified by:
        pause in interface Terminal
        Parameters:
        wait - true to wait until the terminal is actually paused
        Throws:
        java.lang.InterruptedException - if the call has been interrupted
      • paused

        public boolean paused()
        Description copied from interface: Terminal
        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.
        Specified by:
        paused in interface Terminal
        Returns:
        whether the terminal is currently reading the input stream or not
        See Also:
        Terminal.pause(), Terminal.resume()