aerc/ui/types.go

72 lines
1.1 KiB
Go
Raw Normal View History

2018-01-11 04:03:56 +01:00
package ui
2018-01-11 04:41:15 +01:00
import (
tb "github.com/nsf/termbox-go"
"git.sr.ht/~sircmpwn/aerc2/config"
2018-01-11 15:04:18 +01:00
"git.sr.ht/~sircmpwn/aerc2/worker/types"
2018-01-11 04:41:15 +01:00
)
2018-01-11 04:03:56 +01:00
const (
2018-01-11 04:54:55 +01:00
Valid = 0
InvalidateTabList = 1 << iota
InvalidateTabView
2018-01-11 04:03:56 +01:00
InvalidateStatusBar
)
const (
2018-01-11 04:54:55 +01:00
InvalidateAll = InvalidateTabList |
InvalidateTabView |
InvalidateStatusBar
2018-01-11 04:03:56 +01:00
)
type Geometry struct {
2018-01-11 04:41:15 +01:00
Row int
Col int
Width int
Height int
2018-01-11 04:03:56 +01:00
}
type AercTab interface {
Name() string
Render(at Geometry)
2018-01-11 04:41:15 +01:00
SetParent(parent *UIState)
2018-01-11 04:03:56 +01:00
}
2018-01-11 15:04:18 +01:00
type WorkerListener interface {
GetChannel() chan types.WorkerMessage
HandleMessage(msg types.WorkerMessage)
}
type wrappedMessage struct {
msg types.WorkerMessage
listener WorkerListener
}
2018-01-11 04:03:56 +01:00
type UIState struct {
2018-01-11 04:41:15 +01:00
Config *config.AercConfig
2018-01-11 04:03:56 +01:00
Exit bool
InvalidPanes uint
Panes struct {
TabList Geometry
TabView Geometry
Sidebar Geometry
StatusBar Geometry
}
Tabs []AercTab
SelectedTab int
Prompt struct {
Prompt *string
Text *string
Index int
Scroll int
}
2018-01-11 04:41:15 +01:00
tbEvents chan tb.Event
2018-01-11 15:04:18 +01:00
// Aggregate channel for all worker messages
workerEvents chan wrappedMessage
2018-01-11 04:03:56 +01:00
}