chat

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: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SysNick  = "system"
	HelpNick = "help"
	InfoNick = "info"
	ErrNick  = "error"
)
View Source
const (
	COL_DEBUG = iota
	COL_TS
	COL_WHO
	COL_MSG
	COL_SZ
)

Variables

View Source
var (
	Bold       = lipgloss.NewStyle().Bold(true)
	None       = lipgloss.NewStyle()
	AlignRight = lipgloss.NewStyle().Align(lipgloss.Right)

	StyleZeroWidth = lipgloss.NewStyle().Padding(0).Margin(0).Width(0).MaxWidth(0)

	StyleDebugCol = lipgloss.NewStyle().
					MarginRight(1)

	StyleTSCol = lipgloss.NewStyle().
				Faint(true).
				MarginRight(1).
				Align(lipgloss.Right).
				Width(len(time.TimeOnly) + 1).
				MaxWidth(len(time.TimeOnly) + 1)

	VertLine = lipgloss.Border{
		Left:        "│",
		TopRight:    "│",
		Right:       "│",
		BottomRight: "│",
		MiddleRight: "│",
	}

	StyleNick = lipgloss.NewStyle().
				Align(lipgloss.Right).
				Margin(0).
				MarginRight(1).
				Padding(0).
				PaddingRight(1).
				PaddingLeft(0).
				Border(VertLine, false).
				BorderRight(true)

	StyleSysNick = StyleNick.Faint(true)

	StyleMsgCol = lipgloss.NewStyle().
				Align(lipgloss.Left).
				Margin(0).
				Padding(0).
				PaddingLeft(0).
				PaddingRight(1)
	StyleSysMsg = StyleMsgCol.Faint(true)
)

Functions

func FormatTimeAsAge

func FormatTimeAsAge(t time.Time, now time.Time) string

func NickFromWho

func NickFromWho(who string) string

Types

type ChatSizeMsg

type ChatSizeMsg struct {
	Width, Height int
}

type Client

type Client struct {
	Width, Height int

	Send mpty.Input
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, info *mpty.ClientInfoModel, cmds ...Cmd) *Client

func (*Client) At

func (m *Client) At(row, cell int) string

func (*Client) AtRaw

func (m *Client) AtRaw(row int) Msg

func (*Client) ChatViewHeight

func (m *Client) ChatViewHeight() int

func (*Client) Columns

func (m *Client) Columns() int

func (*Client) Err

func (m *Client) Err() error

func (*Client) Id

func (m *Client) Id() mpty.ClientId

func (*Client) Init

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

func (*Client) PrintErrMsg

func (m *Client) PrintErrMsg(err error)

func (*Client) PrintInfoMsg

func (m *Client) PrintInfoMsg(s string)

func (*Client) Rows

func (m *Client) Rows() int

func (*Client) SetSize

func (m *Client) SetSize(w, h int)

func (*Client) SetupCmdPalette

func (m *Client) SetupCmdPalette(additionalCmds ...Cmd)
TODO

-> Available commands: /away [REASON] - Set away reason, or empty to unset. /back - Clear away status. /focus [USER ...] - Only show messages from focused users, or $ to reset. /ignore [USER] - Hide messages from USER, /unignore USER to stop hiding. /msg USER MESSAGE - Send MESSAGE to USER. /nick NAME - Rename yourself. /reply MESSAGE - Reply with MESSAGE to the previous private message. /theme [colors|...] - Set your color theme.

func (*Client) Update

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

func (*Client) UpdateChat

func (m *Client) UpdateChat(msg tea.Msg) (*Client, tea.Cmd)

func (*Client) UpdateClient

func (m *Client) UpdateClient(msg tea.Msg) (mpty.ClientModel, tea.Cmd)

func (*Client) View

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

func (*Client) ViewTo

func (m *Client) ViewTo(w io.Writer)

type Cmd

type Cmd struct {
	// Use is a short use description. The first word will be used as the
	// command
	Use string

	// Aliases is a list of alternative names for the command
	Aliases []string

	// Short is a description that will be displayed in the help
	Short string

	Hidden bool

	// Run is the function that is executed for the command
	Run func(cmd *Cmd, args []string) tea.Cmd
}

type CmdPalette

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

func NewCmdPalette

func NewCmdPalette(leader string, cmds ...Cmd) CmdPalette

func (CmdPalette) Find

func (p CmdPalette) Find(cmd string) *Cmd

func (CmdPalette) Suggestions

func (p CmdPalette) Suggestions() []string

func (CmdPalette) Usage

func (p CmdPalette) Usage() string

type Msg

type Msg struct {
	At time.Time

	Who  string
	Sess string
	Str  string
	// contains filtered or unexported fields
}

func ErrMsg

func ErrMsg(t time.Time, err error) Msg

func HelpMsg

func HelpMsg(t time.Time, msg string) Msg

func InfoMsg

func InfoMsg(t time.Time, msg string) Msg

func SysMsg

func SysMsg(t time.Time, msg string) Msg

func (Msg) Id

func (m Msg) Id() string

func (Msg) Nick

func (m Msg) Nick() string

func (Msg) SetId

func (m Msg) SetId(id int64) mptymsg.Recordable

func (Msg) SetNick

func (m Msg) SetNick(s ...string) Msg

func (Msg) Ts

func (m Msg) Ts() time.Time

func (Msg) TypeName

func (m Msg) TypeName() string

type NamesReq

type NamesReq struct {
	Requestor mpty.ClientId
	Names     []string
}

type ServerModel

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

func (*ServerModel) Init

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

func (*ServerModel) Update

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

func (*ServerModel) UpdateBlokFall

func (m *ServerModel) UpdateBlokFall(msg tea.Msg) tea.Cmd

func (*ServerModel) UpdateChat

func (m *ServerModel) UpdateChat(msg tea.Msg)

func (*ServerModel) View

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

type WhoisReq

type WhoisReq struct {
	Requestor mpty.ClientId
	User      string
	Results   []string
}

Jump to

Keyboard shortcuts

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