tui/viewtmpl.go

45 lines
795 B
Go
Raw Normal View History

2021-01-10 21:52:29 +01:00
package tui
2022-04-01 20:10:51 +02:00
import "github.com/gdamore/tcell"
2021-01-10 21:52:29 +01:00
type ViewTmpl struct {
2022-04-01 20:10:51 +02:00
foreground *Color
background *Color
2021-01-10 21:52:29 +01:00
}
var _ View = &ViewTmpl{}
2022-04-01 20:10:51 +02:00
func (v *ViewTmpl) Draw(buf *ViewBuffer) {
buf.Fill(DefaultRune)
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *ViewTmpl) OnKeyPressed(event *KeyEvent) (consumed bool) {
return false
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *ViewTmpl) Style() Style {
return StyleDefault.Background(v.Background()).Foreground(v.Foreground())
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *ViewTmpl) Foreground() Color {
if v.foreground == nil {
return tcell.ColorDefault
}
return *v.foreground
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *ViewTmpl) SetForeground(color Color) {
v.foreground = &color
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *ViewTmpl) Background() Color {
if v.background == nil {
return tcell.ColorDefault
}
return *v.background
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *ViewTmpl) SetBackground(color Color) {
v.background = &color
2021-01-10 21:52:29 +01:00
}