tty

package
v6.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package tty provides terminal functionality for the Elvish editor.

Index

Constants

View Source
const DefaultSeqTimeout = 10 * time.Millisecond

DefaultSeqTimeout is the amount of time within which runes that make up an escape sequence are supposed to follow each other. Modern terminal emulators send escape sequences very fast, so 10ms is more than sufficient. SSH connections on a slow link might be problematic though.

Variables

This section is empty.

Functions

func Setup

func Setup(in, out *os.File) (func() error, error)

Setup sets up the terminal so that it is suitable for the Reader and Writer to use. It returns a function that can be used to restore the original terminal config.

Types

type CursorPosition

type CursorPosition Pos

CursorPosition represents a report of the current cursor position from the terminal driver, usually as a response from a cursor position request.

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event represents an event that can be read from the terminal.

type FatalErrorEvent

type FatalErrorEvent struct{ Err error }

FatalErrorEvent represents an error that affects the Reader's ability to continue reading events. After sending a FatalError, the Reader makes no more attempts at continuing to read events and wait for Stop to be called.

type KeyEvent

type KeyEvent ui.Key

KeyEvent represents a key press.

type MouseEvent

type MouseEvent struct {
	Pos
	Down bool
	// Number of the Button, 0-based. -1 for unknown.
	Button int
	Mod    ui.Mod
}

MouseEvent represents a mouse event (either pressing or releasing).

type NonfatalErrorEvent

type NonfatalErrorEvent struct{ Err error }

NonfatalErrorEvent represents an error that can be gradually recovered. After sending a NonfatalError, the Reader will continue to read events. Note that one anamoly in the terminal might cause multiple NonfatalError events to be sent.

type PasteSetting

type PasteSetting bool

PasteSetting indicates the start or finish of pasted text.

type Pos

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

Pos is the position in a terminal.

type RawRune

type RawRune rune

RawRune represents a rune read in raw mode.

type Reader

type Reader interface {
	// SetRaw turns the raw mode on or off. In raw mode, the Reader does not
	// decode special sequences, but simply deliver them as RawRune events. If
	// the Reader is in the middle of reading one event, it takes effect after
	// this event is fully read. On platforms (i.e. Windows) where events are
	// not encoded as special sequences, SetRaw has no effect.
	SetRaw(bool)
	// EventChan returns the channel onto which the Reader writes events that it
	// has read.
	EventChan() <-chan Event
	// Start starts the Reader.
	Start()
	// Stop stops the Reader.
	Stop()
	// Close releases resources associated with the Reader. It does not affect
	// resources used to create it.
	Close()
}

Reader reads terminal events and makes them available on a channel.

func NewReader

func NewReader(f *os.File) Reader

NewReader creates a new Reader on the given terminal file. TODO: NewReader should return an error as well. Right now failure to initialize Reader panics.

type Writer

type Writer interface {
	// CurrentBuffer returns the current buffer.
	CurrentBuffer() *ui.Buffer
	// ResetCurrentBuffer resets the current buffer.
	ResetCurrentBuffer()
	// CommitBuffer updates the terminal display to reflect current buffer.
	CommitBuffer(bufNoti, buf *ui.Buffer, fullRefresh bool) error
}

func NewWriter

func NewWriter(f *os.File) Writer

Jump to

Keyboard shortcuts

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