diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-04-10 16:07:16 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-04-10 16:07:16 +0300 |
commit | ee67c1446cbb3c446d59d4ebd9657a25bf0b702d (patch) | |
tree | 8179d7073d3a5fd522937104e1e912131b426919 /ui/messages/meta.go | |
parent | b6e58e83a8ed74f3e0a5f7f0955d264febd542ce (diff) |
Convert message buffer to use custom colorable strings
Diffstat (limited to 'ui/messages/meta.go')
-rw-r--r-- | ui/messages/meta.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/ui/messages/meta.go b/ui/messages/meta.go index 8cb6c1b..3f9c9ab 100644 --- a/ui/messages/meta.go +++ b/ui/messages/meta.go @@ -17,13 +17,16 @@ package messages import ( + "time" + "github.com/gdamore/tcell" "maunium.net/go/gomuks/interface" ) // BasicMeta is a simple variable store implementation of MessageMeta. type BasicMeta struct { - BSender, BTimestamp, BDate string + BSender string + BTimestamp time.Time BSenderColor, BTextColor, BTimestampColor tcell.Color } @@ -37,14 +40,19 @@ func (meta *BasicMeta) SenderColor() tcell.Color { return meta.BSenderColor } -// Timestamp returns the formatted time when the message was sent. -func (meta *BasicMeta) Timestamp() string { +// Timestamp returns the full time when the message was sent. +func (meta *BasicMeta) Timestamp() time.Time { return meta.BTimestamp } -// Date returns the formatted date when the message was sent. -func (meta *BasicMeta) Date() string { - return meta.BDate +// FormatTime returns the formatted time when the message was sent. +func (meta *BasicMeta) FormatTime() string { + return meta.BTimestamp.Format(TimeFormat) +} + +// FormatDate returns the formatted date when the message was sent. +func (meta *BasicMeta) FormatDate() string { + return meta.BTimestamp.Format(DateFormat) } // TextColor returns the color the actual content of the message should be shown in. @@ -63,7 +71,6 @@ func (meta *BasicMeta) TimestampColor() tcell.Color { func (meta *BasicMeta) CopyFrom(from ifc.MessageMeta) { meta.BSender = from.Sender() meta.BTimestamp = from.Timestamp() - meta.BDate = from.Date() meta.BSenderColor = from.SenderColor() meta.BTextColor = from.TextColor() meta.BTimestampColor = from.TimestampColor() |