aboutsummaryrefslogtreecommitdiff
path: root/ui/messages/tstring
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-04-10 21:06:19 +0300
committerTulir Asokan <tulir@maunium.net>2019-04-10 21:06:19 +0300
commitdb0e24ccc268d0a9c7575d660a9397e53747894b (patch)
treec6b3f858cfee7d73ba472842b0f1d4423f118b9a /ui/messages/tstring
parent9132e2b7507c92fc1e49729298344f5d2ed3e9b3 (diff)
Use already parsed events for replies if possible
Diffstat (limited to 'ui/messages/tstring')
-rw-r--r--ui/messages/tstring/string.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/ui/messages/tstring/string.go b/ui/messages/tstring/string.go
index bd6798d..48a6507 100644
--- a/ui/messages/tstring/string.go
+++ b/ui/messages/tstring/string.go
@@ -21,6 +21,7 @@ import (
"unicode"
"github.com/mattn/go-runewidth"
+
"maunium.net/go/mauview"
"maunium.net/go/tcell"
@@ -29,11 +30,11 @@ import (
type TString []Cell
func NewBlankTString() TString {
- return make([]Cell, 0)
+ return make(TString, 0)
}
func NewTString(str string) TString {
- newStr := make([]Cell, len(str))
+ newStr := make(TString, len(str))
for i, char := range str {
newStr[i] = NewCell(char)
}
@@ -41,7 +42,7 @@ func NewTString(str string) TString {
}
func NewColorTString(str string, color tcell.Color) TString {
- newStr := make([]Cell, len(str))
+ newStr := make(TString, len(str))
for i, char := range str {
newStr[i] = NewColorCell(char, color)
}
@@ -49,7 +50,7 @@ func NewColorTString(str string, color tcell.Color) TString {
}
func NewStyleTString(str string, style tcell.Style) TString {
- newStr := make([]Cell, len(str))
+ newStr := make(TString, len(str))
for i, char := range str {
newStr[i] = NewStyleCell(char, style)
}
@@ -74,6 +75,12 @@ func Join(strings []TString, separator string) TString {
return out
}
+func (str TString) Clone() TString {
+ newStr := make(TString, len(str))
+ copy(newStr, str)
+ return newStr
+}
+
func (str TString) AppendTString(dataList ...TString) TString {
newStr := str
for _, data := range dataList {