summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorMoritz Haase <Moritz.Haase@bmw.de>2022-03-24 11:19:08 +0100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-28 09:13:34 +1100
commit9bccc20888bbd92edbb902e35606166e29b12afe (patch)
tree8248580b206d6b5a23161602a26e75093b8f9ac4 /pkg/gui
parentac406f57fff58b20e6dd73a917db842085a96c35 (diff)
pkg/gui: Add support for 'notification' popups
Add a new 'Notification()' method to 'IPopupHandler' that makes it easier to show a modal info message to the user. This is simply a convenience wrapper around 'Ask()', so the popup can be closed using both 'Enter' and 'ESC'.
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/popup/popup_handler.go10
-rw-r--r--pkg/gui/types/common.go4
2 files changed, 13 insertions, 1 deletions
diff --git a/pkg/gui/popup/popup_handler.go b/pkg/gui/popup/popup_handler.go
index c3681fbe6..2d04c052f 100644
--- a/pkg/gui/popup/popup_handler.go
+++ b/pkg/gui/popup/popup_handler.go
@@ -85,6 +85,10 @@ func (self *RealPopupHandler) ErrorMsg(message string) error {
})
}
+func (self *RealPopupHandler) Alert(title string, message string) error {
+ return self.Ask(types.AskOpts{Title: title, Prompt: message})
+}
+
func (self *RealPopupHandler) Ask(opts types.AskOpts) error {
self.Lock()
self.index++
@@ -147,7 +151,7 @@ func (self *RealPopupHandler) WithLoaderPanel(message string, f func() error) er
}
// returns the content that has currently been typed into the prompt. Useful for
-// asyncronously updating the suggestions list under the prompt.
+// asynchronously updating the suggestions list under the prompt.
func (self *RealPopupHandler) GetPromptInput() string {
return self.getPromptInputFn()
}
@@ -168,6 +172,10 @@ func (self *TestPopupHandler) ErrorMsg(message string) error {
return self.OnErrorMsg(message)
}
+func (self *TestPopupHandler) Alert(title string, message string) error {
+ panic("not yet implemented")
+}
+
func (self *TestPopupHandler) Ask(opts types.AskOpts) error {
return self.OnAsk(opts)
}
diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go
index 986dd6664..cbe1cd959 100644
--- a/pkg/gui/types/common.go
+++ b/pkg/gui/types/common.go
@@ -50,6 +50,10 @@ type IGuiCommon interface {
type IPopupHandler interface {
ErrorMsg(message string) error
Error(err error) error
+ // Shows a notification popup with the given title and message to the user.
+ //
+ // This is a convenience wrapper around Ask(), thus the popup can be closed using both 'Enter' and 'ESC'.
+ Alert(title string, message string) error
Ask(opts AskOpts) error
Prompt(opts PromptOpts) error
WithLoaderPanel(message string, f func() error) error