Documentation
¶
Overview ¶
Package messages contains different message types and code to generate and render them.
Index ¶
- Constants
- Variables
- type ExpandedTextMessage
- func (msg *ExpandedTextMessage) CalculateBuffer(prefs config.UserPreferences, width int, uiMsg *UIMessage)
- func (msg *ExpandedTextMessage) Clone() MessageRenderer
- func (msg *ExpandedTextMessage) Draw(screen mauview.Screen, _ *UIMessage)
- func (msg *ExpandedTextMessage) Height() int
- func (msg *ExpandedTextMessage) NotificationContent() string
- func (msg *ExpandedTextMessage) PlainText() string
- func (msg *ExpandedTextMessage) String() string
- type FileMessage
- func (msg *FileMessage) CalculateBuffer(prefs config.UserPreferences, width int, uiMsg *UIMessage)
- func (msg *FileMessage) Clone() MessageRenderer
- func (msg *FileMessage) DownloadPreview()
- func (msg *FileMessage) Draw(screen mauview.Screen, _ *UIMessage)
- func (msg *FileMessage) Height() int
- func (msg *FileMessage) NotificationContent() string
- func (msg *FileMessage) PlainText() string
- func (msg *FileMessage) String() string
- func (msg *FileMessage) ThumbnailPath() string
- type HTMLMessage
- func (hw *HTMLMessage) CalculateBuffer(preferences config.UserPreferences, width int, msg *UIMessage)
- func (hw *HTMLMessage) Clone() MessageRenderer
- func (hw *HTMLMessage) Draw(screen mauview.Screen, msg *UIMessage)
- func (hw *HTMLMessage) Height() int
- func (hw *HTMLMessage) NotificationContent() string
- func (hw *HTMLMessage) OnKeyEvent(event mauview.KeyEvent) bool
- func (hw *HTMLMessage) OnMouseEvent(event mauview.MouseEvent) bool
- func (hw *HTMLMessage) OnPasteEvent(event mauview.PasteEvent) bool
- func (hw *HTMLMessage) PlainText() string
- func (hw *HTMLMessage) String() string
- type MessageRenderer
- type ReactionItem
- type ReactionSlice
- type RedactedMessage
- func (msg *RedactedMessage) CalculateBuffer(prefs config.UserPreferences, width int, uiMsg *UIMessage)
- func (msg *RedactedMessage) Clone() MessageRenderer
- func (msg *RedactedMessage) Draw(screen mauview.Screen, _ *UIMessage)
- func (msg *RedactedMessage) Height() int
- func (msg *RedactedMessage) NotificationContent() string
- func (msg *RedactedMessage) PlainText() string
- func (msg *RedactedMessage) String() string
- type UIMessage
- func NewDateChangeMessage(text string) *UIMessage
- func NewExpandedTextMessage(evt *muksevt.Event, displayname string, text tstring.TString) *UIMessage
- func NewFileMessage(matrix ifc.MatrixContainer, evt *muksevt.Event, displayname string) *UIMessage
- func NewHTMLMessage(evt *muksevt.Event, displayname string, root html.Entity) *UIMessage
- func NewRedactedMessage(evt *muksevt.Event, displayname string) *UIMessage
- func NewServiceMessage(text string) *UIMessage
- func ParseEvent(matrix ifc.MatrixContainer, mainView ifc.MainView, room *rooms.Room, ...) *UIMessage
- func ParseMembershipEvent(room *rooms.Room, evt *muksevt.Event) *UIMessage
- func ParseMessage(matrix ifc.MatrixContainer, room *rooms.Room, evt *muksevt.Event, ...) *UIMessage
- func ParseStateEvent(evt *muksevt.Event, displayname string) *UIMessage
- func (msg *UIMessage) AddReaction(key string)
- func (msg *UIMessage) CalculateBuffer(preferences config.UserPreferences, width int)
- func (msg *UIMessage) CalculateReplyBuffer(preferences config.UserPreferences, width int)
- func (msg *UIMessage) Clone() *UIMessage
- func (msg *UIMessage) Draw(screen mauview.Screen)
- func (msg *UIMessage) DrawReactions(screen mauview.Screen)
- func (msg *UIMessage) DrawReply(screen mauview.Screen) mauview.Screen
- func (msg *UIMessage) FormatDate() string
- func (msg *UIMessage) FormatTime() string
- func (msg *UIMessage) GetEvent() *muksevt.Event
- func (msg *UIMessage) Height() int
- func (msg *UIMessage) ID() id.EventID
- func (msg *UIMessage) NotificationContent() string
- func (msg *UIMessage) NotificationSenderName() string
- func (msg *UIMessage) PlainText() string
- func (msg *UIMessage) ReactionHeight() int
- func (msg *UIMessage) ReplyHeight() int
- func (msg *UIMessage) SameDate(message *UIMessage) bool
- func (msg *UIMessage) Sender() string
- func (msg *UIMessage) SenderColor() tcell.Color
- func (msg *UIMessage) SetID(id id.EventID)
- func (msg *UIMessage) SetIsHighlight(isHighlight bool)
- func (msg *UIMessage) String() string
- func (msg *UIMessage) TextColor() tcell.Color
- func (msg *UIMessage) Time() time.Time
- func (msg *UIMessage) TimestampColor() tcell.Color
Constants ¶
const DateFormat = "January _2, 2006"
const RedactionChar = '█'
const RedactionMaxWidth = 40
const TimeFormat = "15:04:05"
Variables ¶
var RedactionStyle = tcell.StyleDefault.Foreground(tcell.NewRGBColor(50, 0, 0))
Functions ¶
This section is empty.
Types ¶
type ExpandedTextMessage ¶
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) 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 ¶
func (*HTMLMessage) CalculateBuffer ¶
func (hw *HTMLMessage) CalculateBuffer(preferences config.UserPreferences, width int, msg *UIMessage)
func (*HTMLMessage) Clone ¶
func (hw *HTMLMessage) Clone() MessageRenderer
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 ReactionItem ¶
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 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 ¶
NewFileMessage creates a new FileMessage object with the provided values and the default state.
func NewHTMLMessage ¶
func NewRedactedMessage ¶
func NewServiceMessage ¶
func ParseEvent ¶
func ParseMembershipEvent ¶
func ParseMessage ¶
func (*UIMessage) AddReaction ¶
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) DrawReactions ¶
func (*UIMessage) FormatDate ¶
FormatDate returns the formatted date when the message was sent.
func (*UIMessage) FormatTime ¶
FormatTime returns the formatted time when the message was sent.
func (*UIMessage) NotificationContent ¶
func (*UIMessage) NotificationSenderName ¶
func (*UIMessage) ReactionHeight ¶
func (*UIMessage) ReplyHeight ¶
func (*UIMessage) Sender ¶
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 ¶
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) SetIsHighlight ¶
func (*UIMessage) TextColor ¶
TextColor returns the color the actual content of the message should be shown in.
func (*UIMessage) TimestampColor ¶
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.
Source Files
¶
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. |