75 lines
1.2 KiB
Go
75 lines
1.2 KiB
Go
|
package tui
|
||
|
|
||
|
import "github.com/gdamore/tcell"
|
||
|
|
||
|
type WrapperTmpl struct {
|
||
|
ViewTmpl
|
||
|
view View
|
||
|
}
|
||
|
|
||
|
var _ Wrapper = &WrapperTmpl{}
|
||
|
|
||
|
func (v *WrapperTmpl) Draw(buf *ViewBuffer) {
|
||
|
if v.view != nil {
|
||
|
v.view.Draw(buf)
|
||
|
} else {
|
||
|
v.ViewTmpl.Draw(buf)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) OnKeyPressed(event *KeyEvent) (consumed bool) {
|
||
|
if v.view != nil {
|
||
|
return v.view.OnKeyPressed(event)
|
||
|
}
|
||
|
return v.ViewTmpl.OnKeyPressed(event)
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) Style() Style {
|
||
|
if v.view != nil {
|
||
|
return v.view.Style()
|
||
|
}
|
||
|
return v.ViewTmpl.Style()
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) Foreground() Color {
|
||
|
if v.view != nil {
|
||
|
return v.view.Foreground()
|
||
|
}
|
||
|
return v.ViewTmpl.Foreground()
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) SetForeground(color Color) {
|
||
|
if v.view != nil {
|
||
|
v.view.SetForeground(color)
|
||
|
} else {
|
||
|
v.ViewTmpl.SetForeground(color)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) Background() Color {
|
||
|
if v.background == nil {
|
||
|
return tcell.ColorDefault
|
||
|
}
|
||
|
return *v.background
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) SetBackground(color Color) {
|
||
|
if v.view != nil {
|
||
|
v.view.SetBackground(color)
|
||
|
} else {
|
||
|
v.ViewTmpl.SetBackground(color)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) Children() []View {
|
||
|
return []View{v.view}
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) View() View {
|
||
|
return v.view
|
||
|
}
|
||
|
|
||
|
func (v *WrapperTmpl) SetView(view View) {
|
||
|
v.view = view
|
||
|
}
|