diff options
Diffstat (limited to 'termui/input_popup.go')
-rw-r--r-- | termui/input_popup.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/termui/input_popup.go b/termui/input_popup.go index 00e602e5..c8299d2a 100644 --- a/termui/input_popup.go +++ b/termui/input_popup.go @@ -8,10 +8,12 @@ import ( const inputPopupView = "inputPopupView" +// inputPopup is a simple popup with an input field type inputPopup struct { - active bool - title string - c chan string + active bool + title string + preload string + c chan string } func newInputPopup() *inputPopup { @@ -53,6 +55,7 @@ func (ip *inputPopup) layout(g *gocui.Gui) error { v.Frame = true v.Title = ip.title v.Editable = true + v.Write([]byte(ip.preload)) } if _, err := g.SetCurrentView(inputPopupView); err != nil { @@ -88,6 +91,11 @@ func (ip *inputPopup) validate(g *gocui.Gui, v *gocui.View) error { return nil } +func (ip *inputPopup) ActivateWithContent(title string, content string) <-chan string { + ip.preload = content + return ip.Activate(title) +} + func (ip *inputPopup) Activate(title string) <-chan string { ip.title = title ip.active = true |