mpty

package
v0.0.0-...-52eac44 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

mpty provides primitives for creating multiplayer bubbletea applications.

Index

Constants

This section is empty.

Variables

View Source
var (
	Bold = lipgloss.NewStyle().Bold(true)
)

Functions

This section is empty.

Types

type ClientConnectMsg

type ClientConnectMsg ClientId

type ClientDisconnectMsg

type ClientDisconnectMsg ClientId

type ClientId

type ClientId string

type ClientInfoModel

type ClientInfoModel struct {
	Term   string
	Width  int
	Height int
	Time   time.Time

	Sess Session
	Who  *apitype.WhoIsResponse
	// contains filtered or unexported fields
}

func NewClientInfoModelFromSsh

func NewClientInfoModelFromSsh(pty ssh.Pty, sess Session, who *apitype.WhoIsResponse) *ClientInfoModel

func NewClientInfoModelFromWebtty

func NewClientInfoModelFromWebtty(sess Session, who *apitype.WhoIsResponse) *ClientInfoModel

func (*ClientInfoModel) Id

func (m *ClientInfoModel) Id() ClientId

func (*ClientInfoModel) Init

func (m *ClientInfoModel) Init() tea.Cmd

func (*ClientInfoModel) Update

func (m *ClientInfoModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*ClientInfoModel) UpdateInfo

func (m *ClientInfoModel) UpdateInfo(msg tea.Msg) (*ClientInfoModel, tea.Cmd)

func (*ClientInfoModel) View

func (m *ClientInfoModel) View() tea.View

func (*ClientInfoModel) ViewHeight

func (m *ClientInfoModel) ViewHeight() int

type ClientMain

type ClientMain struct {
	Input
	ClientModel
	// contains filtered or unexported fields
}

func (*ClientMain) Init

func (m *ClientMain) Init() tea.Cmd

func (*ClientMain) ReadMsgsCmd

func (m *ClientMain) ReadMsgsCmd() tea.Cmd

func (*ClientMain) Update

func (m *ClientMain) Update(msg tea.Msg) (tea.Model, tea.Cmd)

type ClientModel

type ClientModel interface {
	tea.Model

	UpdateClient(tea.Msg) (ClientModel, tea.Cmd)

	Id() ClientId
	Err() error
}

type Input

type Input chan<- tea.Msg

type Main

type Main struct {
	tea.Model
	// contains filtered or unexported fields
}

func (*Main) Init

func (m *Main) Init() tea.Cmd

func (*Main) Update

func (m *Main) Update(msg tea.Msg) (tea.Model, tea.Cmd)

type NewClientProgram

type NewClientProgram func(context.Context, ClientModel, ...tea.ProgramOption) *tea.Program

type Program

type Program struct {

	// TODO: implement our own minimal tea compatible event loop since this
	// program does not interact with a PTY/TTY at any point
	*tea.Program

	// Send is for a non-blocking many-to-one for clients to communicate with
	// the mpty Program since the tea.Program.Send() API is unfortunately
	// blocking
	Send Input
	// contains filtered or unexported fields
}

func NewProgram

func NewProgram(ctx context.Context, cancel context.CancelCauseFunc, m tea.Model, r Recorder) Program

func (Program) NewClientProgram

func (p Program) NewClientProgram() NewClientProgram

func (Program) StartIn

func (p Program) StartIn(ctx context.Context, grp *errgroup.Group) error

type Recorder

type Recorder interface {
	Save(mptymsg.Recordable) (mptymsg.Recordable, error)
	Read(int) ([]mptymsg.Recordable, error)
}

type Session

type Session interface {
	RemoteAddr() net.Addr
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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