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

Common help code into HelpfulWidget

This commit is contained in:
Chris Cummer
2018-08-01 15:54:29 -07:00
parent 00abe70309
commit 9154441c32
10 changed files with 90 additions and 173 deletions

View File

@@ -36,6 +36,7 @@ const modalWidth = 80
const modalHeight = 7
type Widget struct {
wtf.HelpfulWidget
wtf.TextWidget
app *tview.Application
@@ -46,7 +47,8 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget("Todo", "todo", true),
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
TextWidget: wtf.NewTextWidget("Todo", "todo", true),
app: app,
filePath: wtf.Config.UString("wtf.mods.todo.filename"),
@@ -55,6 +57,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
}
widget.init()
widget.HelpfulWidget.SetView(widget.View)
widget.View.SetScrollable(true)
widget.View.SetRegions(true)
widget.View.SetInputCapture(widget.keyboardIntercept)
@@ -116,7 +120,7 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
widget.display()
return nil
case "/":
widget.showHelp()
widget.ShowHelp()
return nil
case "j":
// Select the next item down
@@ -222,19 +226,6 @@ func (widget *Widget) persist() {
}
}
func (widget *Widget) showHelp() {
closeFunc := func() {
widget.pages.RemovePage("help")
widget.app.SetFocus(widget.View)
}
modal := wtf.NewBillboardModal(HelpText, closeFunc)
widget.pages.AddPage("help", modal, false, true)
widget.app.SetFocus(modal)
widget.app.Draw()
}
/* -------------------- Modal Form -------------------- */
func (widget *Widget) addButtons(form *tview.Form, saveFctn func()) {