Browse Source

Add TextView.SetBytes

tablepad
Trevor Slocum 2 years ago
parent
commit
659788f590
  1. 2
      CHANGELOG
  2. 14
      textview.go

2
CHANGELOG

@ -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

14
textview.go

@ -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 {

Loading…
Cancel
Save