Class ExternalTerminal

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

    public class ExternalTerminal
    extends LineDisciplineTerminal
    Console implementation with embedded line disciplined. This terminal is well-suited for supporting incoming external connections, such as from the network (through telnet, ssh, or any kind of protocol). The terminal will start consuming the input in a separate thread to generate interruption events.
    See Also:
    LineDisciplineTerminal
    • Field Detail

      • closed

        protected final java.util.concurrent.atomic.AtomicBoolean closed
      • masterInput

        protected final java.io.InputStream masterInput
      • lock

        protected final java.lang.Object lock
      • paused

        protected boolean paused
      • pumpThread

        protected java.lang.Thread pumpThread
    • Constructor Detail

      • ExternalTerminal

        public ExternalTerminal​(java.lang.String name,
                                java.lang.String type,
                                java.io.InputStream masterInput,
                                java.io.OutputStream masterOutput,
                                java.nio.charset.Charset encoding)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • ExternalTerminal

        public ExternalTerminal​(TerminalProvider provider,
                                java.lang.String name,
                                java.lang.String type,
                                java.io.InputStream masterInput,
                                java.io.OutputStream masterOutput,
                                java.nio.charset.Charset encoding,
                                Terminal.SignalHandler signalHandler)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • ExternalTerminal

        public ExternalTerminal​(TerminalProvider provider,
                                java.lang.String name,
                                java.lang.String type,
                                java.io.InputStream masterInput,
                                java.io.OutputStream masterOutput,
                                java.nio.charset.Charset encoding,
                                Terminal.SignalHandler signalHandler,
                                boolean paused)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • ExternalTerminal

        public ExternalTerminal​(TerminalProvider provider,
                                java.lang.String name,
                                java.lang.String type,
                                java.io.InputStream masterInput,
                                java.io.OutputStream masterOutput,
                                java.nio.charset.Charset encoding,
                                Terminal.SignalHandler signalHandler,
                                boolean paused,
                                Attributes attributes,
                                Size size)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • 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
        Overrides:
        pause in class AbstractTerminal
        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
        Overrides:
        paused in class AbstractTerminal
        Returns:
        whether the terminal is currently reading the input stream or not
        See Also:
        Terminal.pause(), Terminal.resume()
      • pump

        public void pump()
      • 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