diff --git a/term.go b/term.go index 2bf55d0..644cc4f 100644 --- a/term.go +++ b/term.go @@ -77,14 +77,14 @@ type Terminal struct { ctrlPressed bool altPressed bool } - newLineMode bool // new line mode or line feed mode - bracketedPasteMode bool - state *parseState - blinking bool - printData []byte - printer Printer - cmd *exec.Cmd - middleware Middleware + newLineMode bool // new line mode or line feed mode + bracketedPasteMode bool + state *parseState + blinking bool + printData []byte + printer Printer + cmd *exec.Cmd + readWriterConfigurator ReadWriterConfigurator } // Printer is used for spooling print data when its received. @@ -269,8 +269,8 @@ func (t *Terminal) open() error { } t.in, t.out = in, out - if t.middleware != nil { - t.out, t.in = t.middleware.SetupMiddleware(out, in) + if t.readWriterConfigurator != nil { + t.out, t.in = t.readWriterConfigurator.SetupReadWriter(out, in) } t.pty = pty @@ -359,8 +359,8 @@ func (t *Terminal) RunWithConnection(in io.WriteCloser, out io.Reader) error { time.Sleep(time.Millisecond * 50) } t.in, t.out = in, out - if t.middleware != nil { - t.out, t.in = t.middleware.SetupMiddleware(out, in) + if t.readWriterConfigurator != nil { + t.out, t.in = t.readWriterConfigurator.SetupReadWriter(out, in) } t.run() @@ -505,19 +505,19 @@ func (t *Terminal) DragEnd() { t.selecting = false } -// SetMiddleware sets the middleware function that will be used when creating a new terminal. -// The middleware function is responsible for setting up the I/O readers and writers. -func (t *Terminal) SetMiddleware(mw Middleware) { - t.middleware = mw +// SetReadWriter sets the readWriterConfigurator function that will be used when creating a new terminal. +// The readWriterConfigurator function is responsible for setting up the I/O readers and writers. +func (t *Terminal) SetReadWriter(mw ReadWriterConfigurator) { + t.readWriterConfigurator = mw } -// Middleware is an interface that defines the methods required to set up +// ReadWriterConfigurator is an interface that defines the methods required to set up // the input (reader) and output (writer) streams for the terminal. // Implementations of this interface can modify or wrap the reader and writer. -type Middleware interface { - // SetupMiddleware configures the input and output streams for the terminal. +type ReadWriterConfigurator interface { + // SetupReadWriter configures the input and output streams for the terminal. // It takes an input reader (r) and an output writer (w) as arguments. // The function returns a possibly modified reader and writer that // the terminal will use for I/O operations. - SetupMiddleware(r io.Reader, w io.WriteCloser) (io.Reader, io.WriteCloser) + SetupReadWriter(r io.Reader, w io.WriteCloser) (io.Reader, io.WriteCloser) }