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

Closes #243. Add help window to Todoist module

This commit is contained in:
Chris Cummer 2018-07-25 15:43:29 -07:00
parent cb95737ad2
commit 5d78b79fae

View File

@ -9,6 +9,24 @@ import (
"github.com/senorprogrammer/wtf/wtf" "github.com/senorprogrammer/wtf/wtf"
) )
const HelpText = `
Keyboard commands for Todoist:
/: Show/hide this help window
c: Close the selected item
d: Delete the selected item
h: Previous Todoist list
j: Select the next item in the list
k: Select the previous item in the list
l: Next Todoist list
r: Refresh the todo list data
arrow down: Select the next item in the list
arrow left: Previous Todoist list
arrow right: Next Todoist list
arrow up: Select the previous item in the list
`
type Widget struct { type Widget struct {
wtf.TextWidget wtf.TextWidget
@ -120,6 +138,9 @@ func (w *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
} }
switch string(event.Rune()) { switch string(event.Rune()) {
case "/":
w.showHelp()
return nil
case "r": case "r":
w.Refresh() w.Refresh()
return nil return nil
@ -161,6 +182,18 @@ func loadProjects() []*Project {
return projects return projects
} }
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)
}
func (w *Widget) vimBindings(event *tcell.EventKey) tcell.Key { func (w *Widget) vimBindings(event *tcell.EventKey) tcell.Key {
switch string(event.Rune()) { switch string(event.Rune()) {
case "h": case "h":