mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
implement ui handle waiter (#1930)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,11 @@ import (
|
||||
syftEvent "github.com/anchore/syft/syft/event"
|
||||
)
|
||||
|
||||
var _ bubbly.EventHandler = (*Handler)(nil)
|
||||
var _ interface {
|
||||
bubbly.EventHandler
|
||||
bubbly.MessageListener
|
||||
bubbly.HandleWaiter
|
||||
} = (*Handler)(nil)
|
||||
|
||||
type HandlerConfig struct {
|
||||
TitleWidth int
|
||||
@@ -61,8 +65,12 @@ func New(cfg HandlerConfig) *Handler {
|
||||
return h
|
||||
}
|
||||
|
||||
func (m *Handler) Update(msg tea.Msg) {
|
||||
func (m *Handler) OnMessage(msg tea.Msg) {
|
||||
if msg, ok := msg.(tea.WindowSizeMsg); ok {
|
||||
m.WindowSize = msg
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Handler) Wait() {
|
||||
m.Running.Wait()
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
// that is the responsibility of the frame object on this UI object. The handler is a factory of models
|
||||
// which the frame is responsible for the lifecycle of. This update allows for injecting the initial state
|
||||
// of the world when creating those models.
|
||||
m.handler.Update(msg)
|
||||
m.handler.OnMessage(msg)
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
|
||||
Reference in New Issue
Block a user