tty

package
v0.0.0-...-bd20363 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PositionToEscapeCode

func PositionToEscapeCode(pos view.Position) string

Types

type ByteKey

type ByteKey byte

func NewByteKey

func NewByteKey(r byte) ByteKey

func (ByteKey) Is

func (k ByteKey) Is(key Key) bool

func (ByteKey) Type

func (k ByteKey) Type() KeyType

type Event

type Event interface {
	// Type returns the type of the event.
	Type() EventType
}

type EventType

type EventType int
const (
	// EventTypeResize is the type of a resize event.
	EventType_Resize EventType = iota
	// EventTypeKeyboard is the type of a keyboard event.
	EventType_Keyboard
	// EventTypeMouse is the type of a mouse event.
	EventType_Mouse
)

type InputParser

type InputParser interface {
	// Parse parses the given bytes and returns a slice of events.
	Parse([]byte) []Event
}

type InputReader

type InputReader interface {
	io.ReadWriteCloser
	Fd() uintptr
}

type Key

type Key interface {
	Type() KeyType
	Is(Key) bool
}

type KeyType

type KeyType int
const (
	// KeyTypeByte is the type of a rune key.
	KeyTypeByte KeyType = iota
	// KeyTypeSpecial is the type of a special key.
	KeyTypeSpecial
)

type KeyboardEvent

type KeyboardEvent struct {
	Key       Key
	Modifiers Modifiers
}

func (KeyboardEvent) Is

func (e KeyboardEvent) Is(key Key, mdfr ...Modifiers) bool

func (KeyboardEvent) SetModifiers

func (e KeyboardEvent) SetModifiers(modifiers Modifiers) KeyboardEvent

func (KeyboardEvent) Type

func (e KeyboardEvent) Type() EventType

type Modifiers

type Modifiers byte
const (
	Modifier_None  Modifiers = 0
	Modifier_Shift Modifiers = 1 << iota
	Modifier_Ctrl
	Modifier_Alt
)

type MouseButton

type MouseButton int
const (
	MouseButton_None MouseButton = iota
	MouseButton_Left
	MouseButton_Right
	MouseButton_Middle
)

type MouseEvent

type MouseEvent struct {
	// X is the x coordinate of the mouse event.
	X int
	// Y is the y coordinate of the mouse event.
	Y int
	// Button is the button that was pressed.
	Button MouseButton
	// Modifiers is the set of modifiers that were pressed.
	Modifiers Modifiers
}

func (MouseEvent) SetModifiers

func (e MouseEvent) SetModifiers(modifiers Modifiers) MouseEvent

func (MouseEvent) Type

func (e MouseEvent) Type() EventType

type ResizeEvent

type ResizeEvent struct {
	Width  int
	Height int
}

func (ResizeEvent) Type

func (e ResizeEvent) Type() EventType

type SpecialKey

type SpecialKey string
const (
	SpecialKey_Escape SpecialKey = "\x1b"
	SpecialKey_Enter  SpecialKey = "\r"
	SpecialKey_Up     SpecialKey = "\x1b[A"
	SpecialKey_Down   SpecialKey = "\x1b[B"
	SpecialKey_Right  SpecialKey = "\x1b[C"
	SpecialKey_Left   SpecialKey = "\x1b[D"
	SpecialKey_Insert SpecialKey = "\x1b[2~"
	SpecialKey_Delete SpecialKey = "\x1b[3~"
	SpecialKey_Home   SpecialKey = "\x1b[1~"
	SpecialKey_End    SpecialKey = "\x1b[4~"
	SpecialKey_PageUp SpecialKey = "\x1b[5~"
	SpecialKey_F1     SpecialKey = "\x1bOP"
	SpecialKey_F2     SpecialKey = "\x1bOQ"
	SpecialKey_F3     SpecialKey = "\x1bOR"
	SpecialKey_F4     SpecialKey = "\x1bOS"
	SpecialKey_F5     SpecialKey = "\x1b[15~"
	SpecialKey_F6     SpecialKey = "\x1b[17~"
	SpecialKey_F7     SpecialKey = "\x1b[18~"
	SpecialKey_F8     SpecialKey = "\x1b[19~"
	SpecialKey_F9     SpecialKey = "\x1b[20~"
	SpecialKey_F10    SpecialKey = "\x1b[21~"
	SpecialKey_F11    SpecialKey = "\x1b[23~"
	SpecialKey_F12    SpecialKey = "\x1b[24~"
)

func NewSpecialKey

func NewSpecialKey(key string) SpecialKey

func (SpecialKey) Is

func (k SpecialKey) Is(key Key) bool

func (SpecialKey) Type

func (k SpecialKey) Type() KeyType

type TTY

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

func NewTTY

func NewTTY() (*TTY, error)

func (*TTY) Clear

func (t *TTY) Clear()

func (*TTY) Close

func (t *TTY) Close() error

func (*TTY) DisableCursor

func (t *TTY) DisableCursor()

func (*TTY) SetPos

func (t *TTY) SetPos(x, y int)

func (*TTY) Start

func (t *TTY) Start(ctx context.Context, ch chan Event) error

func (*TTY) Wait

func (t *TTY) Wait()

func (*TTY) Watch

func (t *TTY) Watch(ctx context.Context, echan chan Event) error

func (*TTY) WindowSize

func (t *TTY) WindowSize() (int, int, error)

func (*TTY) Write

func (t *TTY) Write(b []byte) (int, error)

func (*TTY) WritePos

func (t *TTY) WritePos(x, y int, b []byte) (int, error)

Jump to

Keyboard shortcuts

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