aboutsummaryrefslogtreecommitdiff
path: root/ui/types
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-22 19:51:20 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-22 19:54:31 +0200
commit702a75a8c0355737e3e62735b59fe30bee7e42f4 (patch)
tree538b2acd579eabf893fd1f63bc7093b65b620f28 /ui/types
parent232f7fe1be917bf91f6342946f6d001948b8559e (diff)
Save history to disk. Fixes #1
Diffstat (limited to 'ui/types')
-rw-r--r--ui/types/message.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/types/message.go b/ui/types/message.go
index 6775597..e6ded4a 100644
--- a/ui/types/message.go
+++ b/ui/types/message.go
@@ -28,7 +28,7 @@ type Message struct {
BasicMeta
ID string
Text string
- Buffer []string
+ buffer []string
prevBufferWidth int
}
@@ -64,12 +64,12 @@ func (message *Message) CalculateBuffer(width int) {
if width < 2 {
return
}
- message.Buffer = []string{}
+ message.buffer = []string{}
forcedLinebreaks := strings.Split(message.Text, "\n")
newlines := 0
for _, str := range forcedLinebreaks {
if len(str) == 0 && newlines < 1 {
- message.Buffer = append(message.Buffer, "")
+ message.buffer = append(message.buffer, "")
newlines++
} else {
newlines = 0
@@ -87,7 +87,7 @@ func (message *Message) CalculateBuffer(width int) {
extract = extract[:matches[len(matches)-1][1]]
}
}
- message.Buffer = append(message.Buffer, extract)
+ message.buffer = append(message.buffer, extract)
str = str[len(extract):]
}
}
@@ -97,3 +97,11 @@ func (message *Message) CalculateBuffer(width int) {
func (message *Message) RecalculateBuffer() {
message.CalculateBuffer(message.prevBufferWidth)
}
+
+func (message *Message) Buffer() []string {
+ return message.buffer
+}
+
+func (message *Message) Height() int {
+ return len(message.buffer)
+}