io

package
v0.0.0-...-fa00431 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlphaKeyMap = KeyMap{
	Down:      []byte{115},
	Up:        []byte{119},
	Right:     []byte{100},
	Left:      []byte{97},
	PlaceMark: []byte{112},
	Quit:      []byte{3},
}
View Source
var ArrowKeyMap = KeyMap{
	Down:      []byte{27, 91, 66},
	Up:        []byte{27, 91, 65},
	Right:     []byte{27, 91, 67},
	Left:      []byte{27, 91, 68},
	PlaceMark: []byte{32},
	Quit:      []byte{113},
}

Functions

This section is empty.

Types

type DrawEvent

type DrawEvent struct {
	DrawString string
	Terminate  bool
}

func NewDrawEvent

func NewDrawEvent(outputString string, terminate bool) DrawEvent

type InputEvent

type InputEvent struct {
	Move      Move
	Terminate bool
}

func NewInputEvent

func NewInputEvent(move Move) InputEvent

type KeyMap

type KeyMap struct {
	Down      []byte
	Up        []byte
	Right     []byte
	Left      []byte
	PlaceMark []byte
	Quit      []byte
}

---- Constants

type Move

type Move int32
const (
	Move_Noop      Move = 0
	Move_Left      Move = 1
	Move_Right     Move = 2
	Move_Up        Move = 3
	Move_Down      Move = 4
	Move_PlaceMark Move = 5
	Move_Quit      Move = 6
	Request_Move   Move = 7
)

type OutputHandler

type OutputHandler interface {
	RegisterDrawEvents(context.Context, <-chan DrawEvent)
}

type PlayerInputHandler

type PlayerInputHandler interface {
	RegisterInputEvents(context.Context, chan InputEvent)
}

type Terminal

type Terminal struct {
	term.Term
}

Terminal Definition - Matches the IO Handler Interface

func NewTerminal

func NewTerminal() (*Terminal, error)

func (Terminal) Close

func (t Terminal) Close()

func (Terminal) Print

func (t Terminal) Print(outString string)

func (*Terminal) RegisterDrawEvents

func (t *Terminal) RegisterDrawEvents(ctx context.Context, drawChannel <-chan DrawEvent)

func (*Terminal) RegisterInputEvents

func (t *Terminal) RegisterInputEvents(ctx context.Context, playerInput chan InputEvent)

Jump to

Keyboard shortcuts

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