Add TextView.SetBytes

This commit is contained in:
Trevor Slocum 2020-10-04 13:03:28 -07:00
parent da799d93c0
commit 659788f590
2 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,6 @@
v1.5.1 (WIP)
- Store TextView buffer as [][]byte instead of []string
- Add TextView.GetBytes
- Add TextView.SetBytes and TextView.GetBytes
v1.5.0 (2020-10-03)
- Add scroll bar to TextView

View File

@ -303,17 +303,23 @@ func (t *TextView) SetTextColor(color tcell.Color) *TextView {
return t
}
// SetText sets the text of this text view to the provided string. Previously
// contained text will be removed.
func (t *TextView) SetText(text string) *TextView {
// SetBytes sets the text of this text view to the provided byte slice.
// Previously contained text will be removed.
func (t *TextView) SetBytes(text []byte) *TextView {
t.Lock()
defer t.Unlock()
t.clear()
t.write([]byte(text))
t.write(text)
return t
}
// SetText sets the text of this text view to the provided string. Previously
// contained text will be removed.
func (t *TextView) SetText(text string) *TextView {
return t.SetBytes([]byte(text))
}
// GetBytes returns the current text of this text view. If "stripTags" is set
// to true, any region/color tags are stripped from the text.
func (t *TextView) GetBytes(stripTags bool) []byte {