aboutsummaryrefslogtreecommitdiff
path: root/ui/messages/textmessage.go
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-22 22:06:48 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-22 22:06:49 +0300
commit14903e0cdcd3ba78face2cbe0ad0287da269a1ea (patch)
tree664fd5cec84d1728bc704a31955ae03bfe9d32ea /ui/messages/textmessage.go
parent4849ef08b861ee5886f879c320ee6e1d8169f139 (diff)
Add bare mode and fix terminal resize bug. Fixes #48
Diffstat (limited to 'ui/messages/textmessage.go')
-rw-r--r--ui/messages/textmessage.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/ui/messages/textmessage.go b/ui/messages/textmessage.go
index 5139e07..20dcbfc 100644
--- a/ui/messages/textmessage.go
+++ b/ui/messages/textmessage.go
@@ -30,7 +30,7 @@ func init() {
}
type TextMessage struct {
- BaseTextMessage
+ BaseMessage
cache tstring.TString
MsgText string
}
@@ -38,7 +38,7 @@ type TextMessage struct {
// NewTextMessage creates a new UITextMessage object with the provided values and the default state.
func NewTextMessage(id, sender, displayname, msgtype, text string, timestamp time.Time) UIMessage {
return &TextMessage{
- BaseTextMessage: newBaseTextMessage(id, sender, displayname, msgtype, timestamp),
+ BaseMessage: newBaseMessage(id, sender, displayname, msgtype, timestamp),
MsgText: text,
}
}
@@ -57,22 +57,22 @@ func (msg *TextMessage) getCache() tstring.TString {
}
func (msg *TextMessage) SetType(msgtype string) {
- msg.BaseTextMessage.SetType(msgtype)
+ msg.BaseMessage.SetType(msgtype)
msg.cache = nil
}
func (msg *TextMessage) SetState(state ifc.MessageState) {
- msg.BaseTextMessage.SetState(state)
+ msg.BaseMessage.SetState(state)
msg.cache = nil
}
func (msg *TextMessage) SetIsHighlight(isHighlight bool) {
- msg.BaseTextMessage.SetIsHighlight(isHighlight)
+ msg.BaseMessage.SetIsHighlight(isHighlight)
msg.cache = nil
}
func (msg *TextMessage) SetIsService(isService bool) {
- msg.BaseTextMessage.SetIsService(isService)
+ msg.BaseMessage.SetIsService(isService)
msg.cache = nil
}
@@ -80,11 +80,15 @@ func (msg *TextMessage) NotificationContent() string {
return msg.MsgText
}
-func (msg *TextMessage) CalculateBuffer(width int) {
- msg.BaseTextMessage.calculateBufferWithText(msg.getCache(), width)
+func (msg *TextMessage) PlainText() string {
+ return msg.MsgText
+}
+
+func (msg *TextMessage) CalculateBuffer(bare bool, width int) {
+ msg.calculateBufferWithText(bare, msg.getCache(), width)
}
// RecalculateBuffer calculates the buffer again with the previously provided width.
func (msg *TextMessage) RecalculateBuffer() {
- msg.CalculateBuffer(msg.prevBufferWidth)
+ msg.CalculateBuffer(msg.prevBareMode, msg.prevBufferWidth)
}