console

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 7 Imported by: 1,416

README

console

PkgGoDev Build Status Go Report Card

Golang package for dealing with consoles. Light on deps and a simple API.

Modifying the current process

current := console.Current()
defer current.Reset()

if err := current.SetRaw(); err != nil {
}
ws, err := current.Size()
current.Resize(ws)

Project details

console is a containerd sub-project, licensed under the Apache 2.0 license. As a containerd sub-project, you will find the:

information in our containerd/project repository.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAConsole    = errors.New("provided file is not a console")
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type Console

type Console interface {
	File

	// Resize resizes the console to the provided window size
	Resize(WinSize) error
	// ResizeFrom resizes the calling console to the size of the
	// provided console
	ResizeFrom(Console) error
	// SetRaw sets the console in raw mode
	SetRaw() error
	// DisableEcho disables echo on the console
	DisableEcho() error
	// Reset restores the console to its original state
	Reset() error
	// Size returns the window size of the console
	Size() (WinSize, error)
}

func ConsoleFromFile

func ConsoleFromFile(f File) (Console, error)

ConsoleFromFile returns a console using the provided file nolint:revive

func Current

func Current() (c Console)

Current returns the current process' console

func NewPty added in v1.0.4

func NewPty() (Console, string, error)

NewPty creates a new pty pair The master is returned as the first console and a string with the path to the pty slave is returned as the second

type File

type File interface {
	io.ReadWriteCloser

	// Fd returns its file descriptor
	Fd() uintptr
	// Name returns its file name
	Name() string
}

type WinSize

type WinSize struct {
	// Height of the console
	Height uint16
	// Width of the console
	Width uint16
	// contains filtered or unexported fields
}

WinSize specifies the window size of the console

Jump to

Keyboard shortcuts

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