From db0e24ccc268d0a9c7575d660a9397e53747894b Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 10 Apr 2019 21:06:19 +0300 Subject: Use already parsed events for replies if possible --- ui/messages/tstring/string.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'ui/messages/tstring') 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 { -- cgit v1.2.3