diff options
Diffstat (limited to 'pkg/gui/popup/popup_handler.go')
-rw-r--r-- | pkg/gui/popup/popup_handler.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/gui/popup/popup_handler.go b/pkg/gui/popup/popup_handler.go index adc276d5f..bba0e52a8 100644 --- a/pkg/gui/popup/popup_handler.go +++ b/pkg/gui/popup/popup_handler.go @@ -19,6 +19,8 @@ type IPopupHandler interface { WithLoaderPanel(message string, f func() error) error WithWaitingStatus(message string, f func() error) error Menu(opts CreateMenuOptions) error + Toast(message string) + GetPromptInput() string } type CreateMenuOptions struct { @@ -74,6 +76,8 @@ type RealPopupHandler struct { closePopupFn func() error createMenuFn func(CreateMenuOptions) error withWaitingStatusFn func(message string, f func() error) error + toastFn func(message string) + getPromptInputFn func() string } var _ IPopupHandler = &RealPopupHandler{} @@ -85,6 +89,8 @@ func NewPopupHandler( closePopupFn func() error, createMenuFn func(CreateMenuOptions) error, withWaitingStatusFn func(message string, f func() error) error, + toastFn func(message string), + getPromptInputFn func() string, ) *RealPopupHandler { return &RealPopupHandler{ Common: common, @@ -94,6 +100,8 @@ func NewPopupHandler( closePopupFn: closePopupFn, createMenuFn: createMenuFn, withWaitingStatusFn: withWaitingStatusFn, + toastFn: toastFn, + getPromptInputFn: getPromptInputFn, } } @@ -101,6 +109,10 @@ func (self *RealPopupHandler) Menu(opts CreateMenuOptions) error { return self.createMenuFn(opts) } +func (self *RealPopupHandler) Toast(message string) { + self.toastFn(message) +} + func (self *RealPopupHandler) WithWaitingStatus(message string, f func() error) error { return self.withWaitingStatusFn(message, f) } @@ -188,6 +200,12 @@ func (self *RealPopupHandler) WithLoaderPanel(message string, f func() error) er return nil } +// returns the content that has currently been typed into the prompt. Useful for +// asyncronously updating the suggestions list under the prompt. +func (self *RealPopupHandler) GetPromptInput() string { + return self.getPromptInputFn() +} + type TestPopupHandler struct { OnErrorMsg func(message string) error OnAsk func(opts AskOpts) error @@ -221,3 +239,11 @@ func (self *TestPopupHandler) WithWaitingStatus(message string, f func() error) func (self *TestPopupHandler) Menu(opts CreateMenuOptions) error { panic("not yet implemented") } + +func (self *TestPopupHandler) Toast(message string) { + panic("not yet implemented") +} + +func (self *TestPopupHandler) CurrentInput() string { + panic("not yet implemented") +} |