tty

package
v0.0.0-...-1a7aca4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultScrollback defines the terminal scrollback in lines.
	DefaultScrollback = 80

	// DefaultTabWidth defines the number of spaces that tabs expand to.
	DefaultTabWidth = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device interface {
	io.Writer
	io.ByteWriter

	// AttachTo connects a TTY to a console instance.
	AttachTo(console.Device)

	// State returns the TTY's state.
	State() State

	// SetState updates the TTY's state.
	SetState(State)

	// CursorPosition returns the current cursor x,y coordinates. Both
	// coordinates are 1-based (top-left corner has coordinates 1,1).
	CursorPosition() (uint32, uint32)

	// SetCursorPosition sets the current cursor position to (x,y). Both
	// coordinates are 1-based (top-left corner has coordinates 1,1).
	// Implementations are expected to clip the cursor position to their
	// viewport.
	SetCursorPosition(x, y uint32)
}

Device is implemented by objects that can be used as a terminal device.

type State

type State uint8

State defines the supported terminal state values.

const (
	// StateInactive marks the terminal as inactive. Any writes will be
	// buffered and not synced to the attached console.
	StateInactive State = iota

	// StateActive marks the terminal as active. Any writes will be
	// buffered and also synced to the attached console.
	StateActive
)

type VT

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

VT implements a terminal supporting scrollback. The terminal interprets the following special characters:

  • \r (carriage-return)
  • \n (line-feed)
  • \b (backspace)
  • \t (tab; expanded to tabWidth spaces)

func NewVT

func NewVT(tabWidth uint8, scrollback uint32) *VT

NewVT creates a new virtual terminal device. The tabWidth parameter controls tab expansion whereas the scrollback parameter defines the line count that gets buffered by the terminal to provide scrolling beyond the console height.

func (*VT) AttachTo

func (t *VT) AttachTo(cons console.Device)

AttachTo connects a TTY to a console instance.

func (*VT) CursorPosition

func (t *VT) CursorPosition() (uint32, uint32)

CursorPosition returns the current cursor position.

func (*VT) DriverInit

func (t *VT) DriverInit(_ io.Writer) *kernel.Error

DriverInit initializes this driver.

func (*VT) DriverName

func (t *VT) DriverName() string

DriverName returns the name of this driver.

func (*VT) DriverVersion

func (t *VT) DriverVersion() (uint16, uint16, uint16)

DriverVersion returns the version of this driver.

func (*VT) SetCursorPosition

func (t *VT) SetCursorPosition(x, y uint32)

SetCursorPosition sets the current cursor position to (x,y).

func (*VT) SetState

func (t *VT) SetState(newState State)

SetState updates the TTY's state.

func (*VT) State

func (t *VT) State() State

State returns the TTY's state.

func (*VT) Write

func (t *VT) Write(data []byte) (int, error)

Write implements io.Writer.

func (*VT) WriteByte

func (t *VT) WriteByte(b byte) error

WriteByte implements io.ByteWriter.

Jump to

Keyboard shortcuts

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