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:
parent
cb95737ad2
commit
5d78b79fae
@ -9,6 +9,24 @@ import (
|
||||
"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 {
|
||||
wtf.TextWidget
|
||||
|
||||
@ -120,6 +138,9 @@ func (w *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
}
|
||||
|
||||
switch string(event.Rune()) {
|
||||
case "/":
|
||||
w.showHelp()
|
||||
return nil
|
||||
case "r":
|
||||
w.Refresh()
|
||||
return nil
|
||||
@ -161,6 +182,18 @@ func loadProjects() []*Project {
|
||||
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 {
|
||||
switch string(event.Rune()) {
|
||||
case "h":
|
||||
|
Loading…
x
Reference in New Issue
Block a user