Files
tasksquire/common/common.go
Martin Pander 14dbfc406d [WIP] Layout
2024-05-22 16:20:57 +02:00

51 lines
795 B
Go

package common
import (
"context"
"tasksquire/taskwarrior"
)
type Common struct {
Ctx context.Context
TW taskwarrior.TaskWarrior
Keymap *Keymap
Styles *Styles
pageStack *Stack[Component]
width int
height int
}
func NewCommon(ctx context.Context, tw taskwarrior.TaskWarrior) *Common {
return &Common{
Ctx: ctx,
TW: tw,
Keymap: NewKeymap(),
Styles: NewStyles(tw.GetConfig()),
pageStack: NewStack[Component](),
}
}
func (c *Common) SetSize(width, height int) {
c.width = width
c.height = height
}
func (c *Common) Width() int {
return c.width
}
func (c *Common) Height() int {
return c.height
}
func (c *Common) PushPage(page Component) {
c.pageStack.Push(page)
}
func (c *Common) PopPage() (Component, error) {
return c.pageStack.Pop()
}