messages

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package messages contains different message types and code to generate and render them.

Index

Constants

View Source
const DateFormat = "January _2, 2006"
View Source
const RedactionChar = '█'
View Source
const RedactionMaxWidth = 40
View Source
const TimeFormat = "15:04:05"

Variables

View Source
var RedactionStyle = tcell.StyleDefault.Foreground(tcell.NewRGBColor(50, 0, 0))

Functions

This section is empty.

Types

type ExpandedTextMessage

type ExpandedTextMessage struct {
	Text tstring.TString
	// contains filtered or unexported fields
}

func (*ExpandedTextMessage) CalculateBuffer

func (msg *ExpandedTextMessage) CalculateBuffer(prefs config.UserPreferences, width int, uiMsg *UIMessage)

func (*ExpandedTextMessage) Clone

func (msg *ExpandedTextMessage) Clone() MessageRenderer

func (*ExpandedTextMessage) Draw

func (msg *ExpandedTextMessage) Draw(screen mauview.Screen, _ *UIMessage)

func (*ExpandedTextMessage) Height

func (msg *ExpandedTextMessage) Height() int

func (*ExpandedTextMessage) NotificationContent

func (msg *ExpandedTextMessage) NotificationContent() string

func (*ExpandedTextMessage) PlainText

func (msg *ExpandedTextMessage) PlainText() string

func (*ExpandedTextMessage) String

func (msg *ExpandedTextMessage) String() string

type FileMessage

type FileMessage struct {
	Type event.MessageType
	Body string

	URL           id.ContentURI
	File          *attachment.EncryptedFile
	Thumbnail     id.ContentURI
	ThumbnailFile *attachment.EncryptedFile
	// contains filtered or unexported fields
}

func (*FileMessage) CalculateBuffer

func (msg *FileMessage) CalculateBuffer(prefs config.UserPreferences, width int, uiMsg *UIMessage)

func (*FileMessage) Clone

func (msg *FileMessage) Clone() MessageRenderer

func (*FileMessage) DownloadPreview

func (msg *FileMessage) DownloadPreview()

func (*FileMessage) Draw

func (msg *FileMessage) Draw(screen mauview.Screen, _ *UIMessage)

func (*FileMessage) Height

func (msg *FileMessage) Height() int

func (*FileMessage) NotificationContent

func (msg *FileMessage) NotificationContent() string

func (*FileMessage) PlainText

func (msg *FileMessage) PlainText() string

func (*FileMessage) String

func (msg *FileMessage) String() string

func (*FileMessage) ThumbnailPath

func (msg *FileMessage) ThumbnailPath() string

type HTMLMessage

type HTMLMessage struct {
	Root      html.Entity
	TextColor tcell.Color
}

func (*HTMLMessage) CalculateBuffer

func (hw *HTMLMessage) CalculateBuffer(preferences config.UserPreferences, width int, msg *UIMessage)

func (*HTMLMessage) Clone

func (hw *HTMLMessage) Clone() MessageRenderer

func (*HTMLMessage) Draw

func (hw *HTMLMessage) Draw(screen mauview.Screen, msg *UIMessage)

func (*HTMLMessage) Height

func (hw *HTMLMessage) Height() int

func (*HTMLMessage) NotificationContent

func (hw *HTMLMessage) NotificationContent() string

func (*HTMLMessage) OnKeyEvent

func (hw *HTMLMessage) OnKeyEvent(event mauview.KeyEvent) bool

func (*HTMLMessage) OnMouseEvent

func (hw *HTMLMessage) OnMouseEvent(event mauview.MouseEvent) bool

func (*HTMLMessage) OnPasteEvent

func (hw *HTMLMessage) OnPasteEvent(event mauview.PasteEvent) bool

func (*HTMLMessage) PlainText

func (hw *HTMLMessage) PlainText() string

func (*HTMLMessage) String

func (hw *HTMLMessage) String() string

type MessageRenderer

type MessageRenderer interface {
	Draw(screen mauview.Screen, msg *UIMessage)
	NotificationContent() string
	PlainText() string
	CalculateBuffer(prefs config.UserPreferences, width int, msg *UIMessage)
	Height() int
	Clone() MessageRenderer
	String() string
}

type ReactionItem

type ReactionItem struct {
	Key   string
	Count int
}

func (ReactionItem) String

func (ri ReactionItem) String() string

type ReactionSlice

type ReactionSlice []ReactionItem

func (ReactionSlice) Len

func (rs ReactionSlice) Len() int

func (ReactionSlice) Less

func (rs ReactionSlice) Less(i, j int) bool

func (ReactionSlice) Swap

func (rs ReactionSlice) Swap(i, j int)

type RedactedMessage

type RedactedMessage struct{}

func (*RedactedMessage) CalculateBuffer

func (msg *RedactedMessage) CalculateBuffer(prefs config.UserPreferences, width int, uiMsg *UIMessage)

func (*RedactedMessage) Clone

func (msg *RedactedMessage) Clone() MessageRenderer

func (*RedactedMessage) Draw

func (msg *RedactedMessage) Draw(screen mauview.Screen, _ *UIMessage)

func (*RedactedMessage) Height

func (msg *RedactedMessage) Height() int

func (*RedactedMessage) NotificationContent

func (msg *RedactedMessage) NotificationContent() string

func (*RedactedMessage) PlainText

func (msg *RedactedMessage) PlainText() string

func (*RedactedMessage) String

func (msg *RedactedMessage) String() string

type UIMessage

type UIMessage struct {
	EventID            id.EventID
	TxnID              string
	Relation           event.RelatesTo
	Type               event.MessageType
	SenderID           id.UserID
	SenderName         string
	DefaultSenderColor tcell.Color
	Timestamp          time.Time
	State              muksevt.OutgoingState
	IsHighlight        bool
	IsService          bool
	IsSelected         bool
	Edited             bool
	Event              *muksevt.Event
	ReplyTo            *UIMessage
	Reactions          ReactionSlice
	Renderer           MessageRenderer
}

func NewDateChangeMessage

func NewDateChangeMessage(text string) *UIMessage

func NewExpandedTextMessage

func NewExpandedTextMessage(evt *muksevt.Event, displayname string, text tstring.TString) *UIMessage

NewExpandedTextMessage creates a new ExpandedTextMessage object with the provided values and the default state.

func NewFileMessage

func NewFileMessage(matrix ifc.MatrixContainer, evt *muksevt.Event, displayname string) *UIMessage

NewFileMessage creates a new FileMessage object with the provided values and the default state.

func NewHTMLMessage

func NewHTMLMessage(evt *muksevt.Event, displayname string, root html.Entity) *UIMessage

func NewRedactedMessage

func NewRedactedMessage(evt *muksevt.Event, displayname string) *UIMessage

func NewServiceMessage

func NewServiceMessage(text string) *UIMessage

func ParseEvent

func ParseEvent(matrix ifc.MatrixContainer, mainView ifc.MainView, room *rooms.Room, evt *muksevt.Event) *UIMessage

func ParseMembershipEvent

func ParseMembershipEvent(room *rooms.Room, evt *muksevt.Event) *UIMessage

func ParseMessage

func ParseMessage(matrix ifc.MatrixContainer, room *rooms.Room, evt *muksevt.Event, displayname string) *UIMessage

func ParseStateEvent

func ParseStateEvent(evt *muksevt.Event, displayname string) *UIMessage

func (*UIMessage) AddReaction

func (msg *UIMessage) AddReaction(key string)

func (*UIMessage) CalculateBuffer

func (msg *UIMessage) CalculateBuffer(preferences config.UserPreferences, width int)

func (*UIMessage) CalculateReplyBuffer

func (msg *UIMessage) CalculateReplyBuffer(preferences config.UserPreferences, width int)

func (*UIMessage) Clone

func (msg *UIMessage) Clone() *UIMessage

func (*UIMessage) Draw

func (msg *UIMessage) Draw(screen mauview.Screen)

func (*UIMessage) DrawReactions

func (msg *UIMessage) DrawReactions(screen mauview.Screen)

func (*UIMessage) DrawReply

func (msg *UIMessage) DrawReply(screen mauview.Screen) mauview.Screen

func (*UIMessage) FormatDate

func (msg *UIMessage) FormatDate() string

FormatDate returns the formatted date when the message was sent.

func (*UIMessage) FormatTime

func (msg *UIMessage) FormatTime() string

FormatTime returns the formatted time when the message was sent.

func (*UIMessage) GetEvent

func (msg *UIMessage) GetEvent() *muksevt.Event

func (*UIMessage) Height

func (msg *UIMessage) Height() int

Height returns the number of rows in the computed buffer (see Buffer()).

func (*UIMessage) ID

func (msg *UIMessage) ID() id.EventID

func (*UIMessage) NotificationContent

func (msg *UIMessage) NotificationContent() string

func (*UIMessage) NotificationSenderName

func (msg *UIMessage) NotificationSenderName() string

func (*UIMessage) PlainText

func (msg *UIMessage) PlainText() string

func (*UIMessage) ReactionHeight

func (msg *UIMessage) ReactionHeight() int

func (*UIMessage) ReplyHeight

func (msg *UIMessage) ReplyHeight() int

func (*UIMessage) SameDate

func (msg *UIMessage) SameDate(message *UIMessage) bool

func (*UIMessage) Sender

func (msg *UIMessage) Sender() string

Sender gets the string that should be displayed as the sender of this message.

If the message is being sent, the sender is "Sending...". If sending has failed, the sender is "Error". If the message is an emote, the sender is blank. In any other case, the sender is the display name of the user who sent the message.

func (*UIMessage) SenderColor

func (msg *UIMessage) SenderColor() tcell.Color

SenderColor returns the color the name of the sender should be shown in.

If the message is being sent, the color is gray. If sending has failed, the color is red.

In any other case, the color is whatever is specified in the Message struct. Usually that means it is the hash-based color of the sender (see ui/widget/color.go)

func (*UIMessage) SetID

func (msg *UIMessage) SetID(id id.EventID)

func (*UIMessage) SetIsHighlight

func (msg *UIMessage) SetIsHighlight(isHighlight bool)

func (*UIMessage) String

func (msg *UIMessage) String() string

func (*UIMessage) TextColor

func (msg *UIMessage) TextColor() tcell.Color

TextColor returns the color the actual content of the message should be shown in.

func (*UIMessage) Time

func (msg *UIMessage) Time() time.Time

func (*UIMessage) TimestampColor

func (msg *UIMessage) TimestampColor() tcell.Color

TimestampColor returns the color the timestamp should be shown in.

As with SenderColor(), messages being sent and messages that failed to be sent are gray and red respectively.

However, other messages are the default color instead of a color stored in the struct.

Directories

Path Synopsis
gomuks - A terminal Matrix client written in Go.
gomuks - A terminal Matrix client written in Go.
Package tstring contains a string type that stores style data for each character, allowing it to be rendered to a tcell screen essentially unmodified.
Package tstring contains a string type that stores style data for each character, allowing it to be rendered to a tcell screen essentially unmodified.

Jump to

Keyboard shortcuts

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