terminal

package
v11.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2021 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResizeEvent

type ResizeEvent struct{}

ResizeEvent is emitted when a terminal window is resized.

type StopEvent

type StopEvent struct{}

StopEvent is emitted when the user sends a SIGSTOP

type Terminal

type Terminal struct {
	// contains filtered or unexported fields
}

Terminal is used to configure raw input and output modes for an attached terminal emulator.

func New

func New(stdin io.Reader, stdout, stderr io.Writer) (*Terminal, error)

New creates a new Terminal instance. Callers should call `InitRaw` to configure the terminal for raw input or output modes.

Note that the returned Terminal instance must be closed to ensure the terminal is properly reset; unexpected exits may leave users' terminals unusable.

func (*Terminal) Clear

func (t *Terminal) Clear() error

Clear clears the terminal, including scrollback.

func (*Terminal) Close

func (t *Terminal) Close() error

Close closes the Terminal, restoring the console to its original state.

func (*Terminal) InitRaw

func (t *Terminal) InitRaw(input bool) error

InitRaw puts the terminal into raw mode. On Unix, no special input handling is required beyond simply reading from stdin, so `input` has no effect. Note that some implementations may replace one or more streams (particularly stdin).

func (*Terminal) IsAttached

func (t *Terminal) IsAttached() bool

IsAttached determines if this terminal is attached to an interactive console session.

func (*Terminal) Resize

func (t *Terminal) Resize(width, height int16) error

Resize makes a best-effort attempt to resize the terminal window. Support varies between platforms and terminal emulators.

func (*Terminal) Size

func (t *Terminal) Size() (width int16, height int16, err error)

Size fetches the current terminal size as measured in columns and rows.

func (*Terminal) Stderr

func (t *Terminal) Stderr() io.Writer

func (*Terminal) Stdin

func (t *Terminal) Stdin() io.Reader

func (*Terminal) Stdout

func (t *Terminal) Stdout() io.Writer

func (*Terminal) Subscribe

func (e *Terminal) Subscribe() chan interface{}

Subscribe creates a channel that will receive terminal events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL