1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

A crap version that uses tview's Modal

This commit is contained in:
Chris Cummer
2018-05-03 11:26:53 -07:00
parent 6ccdbabec9
commit 53d2fdacda
2 changed files with 15 additions and 58 deletions

View File

@@ -16,12 +16,8 @@ import (
var Config *config.Config
const helpText = `
Todo
h - Displays the help text
o - Opens the todo file in the operating system
space - checks an item on or off
h: Displays the help text. o: Opens the todo file in the operating system.
space: Checks an item on or off
`
type Widget struct {
@@ -86,16 +82,19 @@ func (widget *Widget) editItem() {
}
func (widget *Widget) help() {
cancelFn := func() {
widget.pages.RemovePage("billboard")
cancelFn := func(idx int, label string) {
widget.pages.RemovePage("help")
widget.app.SetFocus(widget.View)
widget.display()
}
billboard := wtf.NewBillboardModal(helpText, cancelFn)
helpModal := tview.NewModal()
helpModal.SetText(helpText)
helpModal.AddButtons([]string{"Close"})
helpModal.SetDoneFunc(cancelFn)
widget.pages.AddPage("billboard", billboard, false, true)
widget.app.SetFocus(billboard)
widget.pages.AddPage("help", helpModal, false, true)
widget.app.SetFocus(helpModal)
}
func (widget *Widget) init() {
@@ -228,11 +227,14 @@ func (widget *Widget) addButtons(form *tview.Form, saveFctn func()) {
}
func (widget *Widget) addCancelButton(form *tview.Form) {
form.AddButton("Cancel", func() {
cancelFn := func() {
widget.pages.RemovePage("modal")
widget.app.SetFocus(widget.View)
widget.display()
})
}
form.AddButton("Cancel", cancelFn)
form.SetCancelFunc(cancelFn)
}
func (widget *Widget) addSaveButton(form *tview.Form, fctn func()) {