ui

package
v0.0.0-...-b59fb02 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Image2ANSI

func Image2ANSI(img image.Image, cols, rows int, aspect float64, lightBackground bool) []byte

Types

type BackspaceEvent

type BackspaceEvent struct{}

BackspaceEvent is fired when the backspace button is pressed.

type ConnEndedEvent

type ConnEndedEvent struct {
	// The reason for the disconnection
	Reason EndConnReason
}

ConnEndedEvent fires when the connection with your partner has been lost

type ConnStartedEvent

type ConnStartedEvent struct{}

ConnStartedEvent fires when an ICE connection has been established and the call can begin

type DataOpenedEvent

type DataOpenedEvent struct{}

DataOpenedEvent fires when the text chat data channel opens and the user can begin typing

type EndConnReason

type EndConnReason int
const (
	// User closed connection
	EndConnNormal EndConnReason = iota
	// Error during connection setup
	EndConnSetupError
	// Error during matching
	EndConnMatchError
	// Connection timed out
	EndConnTimedOut
	// Lost connection with partner
	EndConnDisconnected
	// Partner left
	EndConnGone
)

type Event

type Event interface{}

An Event represents a user action that cause changes in the UI state.

They're processed by Renderer's Dispatch method.

type FrameEvent

type FrameEvent image.Image

FrameEvent is sent when the video decoder renders a new frame

type KeypressEvent

type KeypressEvent rune

KeypressEvent is fired when the user presses the keyboard.

type LogEvent

type LogEvent struct {
	Text  string
	Level LogLevel
}

A LogEvent prints a message to the console

type LogLevel

type LogLevel int

LogLevel indicates the severity of a LogEvent message

const (
	// LogLevelInfo is for non-urgent, informational logs
	LogLevelInfo LogLevel = iota
	// LogLevelError is for logs that indicate problems
	LogLevelError
)

type Message

type Message struct {
	Type MessageType
	User string
	Text string
}

type MessageType

type MessageType int
const (
	MessageTypeIncoming MessageType = iota
	MessageTypeOutgoing
	MessageTypeInfo
	MessageTypeError
)

type Page

type Page string
var (
	GlobePage   Page = "globe"
	PionPage    Page = "pion"
	ConfirmPage Page = "confirm"
	ChatPage    Page = "chat"
)

type ReceivedChatEvent

type ReceivedChatEvent string

ReceivedChatEvent is fired when the user submits text in the chat input box.

type Renderer

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

func NewRenderer

func NewRenderer() *Renderer

func (*Renderer) Dispatch

func (r *Renderer) Dispatch(e Event)

func (*Renderer) GetState

func (r *Renderer) GetState() State

func (*Renderer) RequestFrame

func (r *Renderer) RequestFrame()

func (*Renderer) Start

func (r *Renderer) Start()

func (*Renderer) Stop

func (r *Renderer) Stop()

type ResizeEvent

type ResizeEvent term.WinSize

ResizeEvent indicates that the terminal window's size has changed to the specified dimensions

type SentMessageEvent

type SentMessageEvent string

SentMessageEvent fires after a message has been sent to the current partner

type SetPageEvent

type SetPageEvent Page

SetPageEvent transitions to the specified page

type SkipEvent

type SkipEvent struct{}

SkipEvent skips to the next match

type State

type State struct {
	Page Page

	HelpOn bool

	Input      string
	ChatActive bool

	Messages []Message
	Image    image.Image
	WinSize  term.WinSize
}

func StateReducer

func StateReducer(s State, event Event) State

type ToggleHelpEvent

type ToggleHelpEvent struct{}

ToggleHelpEvent toggles the help modal

Jump to

Keyboard shortcuts

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