diff --git a/github/display.go b/github/display.go index b546507e..089b7348 100644 --- a/github/display.go +++ b/github/display.go @@ -39,7 +39,7 @@ func (widget *Widget) openPRs(repo *GithubRepo, username string) string { user := *pr.User if *user.Login == username { - str = str + fmt.Sprintf(" [green]%d[white] %s\n", *pr.Number, *pr.Title) + str = str + fmt.Sprintf(" [green]%4d[white] %s\n", *pr.Number, *pr.Title) } } diff --git a/todo/widget.go b/todo/widget.go index 278cf540..301fe461 100644 --- a/todo/widget.go +++ b/todo/widget.go @@ -15,6 +15,15 @@ import ( // Config is a pointer to the global config object 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 +` + type Widget struct { wtf.TextWidget @@ -76,21 +85,17 @@ func (widget *Widget) editItem() { widget.modalFocus(form) } -func (widget *Widget) newItem() { - form := widget.modalForm("New:", "") - - saveFctn := func() { - text := form.GetFormItem(0).(*tview.InputField).GetText() - - widget.list.Add(text) - widget.persist() - widget.pages.RemovePage("modal") +func (widget *Widget) help() { + cancelFn := func() { + widget.pages.RemovePage("billboard") widget.app.SetFocus(widget.View) widget.display() } - widget.addButtons(form, saveFctn) - widget.modalFocus(form) + billboard := wtf.NewBillboardModal(helpText, cancelFn) + + widget.pages.AddPage("billboard", billboard, false, true) + widget.app.SetFocus(billboard) } func (widget *Widget) init() { @@ -110,7 +115,7 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey { return nil case "h": // Show help menu - fmt.Println("HELP!") + widget.help() return nil case "j": // Select the next item down @@ -198,6 +203,23 @@ func (widget *Widget) persist() { } } +func (widget *Widget) newItem() { + form := widget.modalForm("New:", "") + + saveFctn := func() { + text := form.GetFormItem(0).(*tview.InputField).GetText() + + widget.list.Add(text) + widget.persist() + widget.pages.RemovePage("modal") + widget.app.SetFocus(widget.View) + widget.display() + } + + widget.addButtons(form, saveFctn) + widget.modalFocus(form) +} + /* -------------------- Modal Form -------------------- */ func (widget *Widget) addButtons(form *tview.Form, saveFctn func()) { diff --git a/wtf/billboard_modal.go b/wtf/billboard_modal.go new file mode 100644 index 00000000..f217e675 --- /dev/null +++ b/wtf/billboard_modal.go @@ -0,0 +1,45 @@ +package wtf + +import ( + "github.com/gdamore/tcell" + "github.com/rivo/tview" +) + +type BillboardModal struct{} + +func NewBillboardModal(text string, cancelFn func()) *tview.Frame { + modal := BillboardModal{} + + frame := modal.build(cancelFn) + frame.AddText(text, false, tview.AlignLeft, tcell.ColorWhite) + + return frame +} + +/* -------------------- Unexported Functions -------------------- */ + +func (modal *BillboardModal) build(cancelFn func()) *tview.Frame { + form := modal.buildForm(cancelFn) + frame := modal.buildFrame(form) + + return frame +} + +func (modal *BillboardModal) buildForm(cancelFn func()) *tview.Form { + form := tview.NewForm(). + SetButtonsAlign(tview.AlignCenter). + SetButtonTextColor(tview.Styles.PrimaryTextColor) + + form.AddButton("Cancel", cancelFn) + + return form +} + +func (modal *BillboardModal) buildFrame(form *tview.Form) *tview.Frame { + + frame := tview.NewFrame(form).SetBorders(0, 0, 0, 0, 0, 0) + frame.SetBorder(true) + frame.SetRect(20, 20, 80, 20) + + return frame +}