mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Better keyboard support for todo
This commit is contained in:
parent
a92af549fe
commit
34dcdbbe66
@ -4,7 +4,6 @@ import ()
|
||||
|
||||
type Item struct {
|
||||
Checked bool
|
||||
Index int
|
||||
Text string
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ type List struct {
|
||||
}
|
||||
|
||||
func (list *List) Delete() {
|
||||
fmt.Println("del")
|
||||
list.Items = append(list.Items[:list.selected], list.Items[list.selected+1:]...)
|
||||
}
|
||||
|
||||
|
@ -67,30 +67,42 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
case "e":
|
||||
// Edit selected item
|
||||
return nil
|
||||
case "h":
|
||||
// Show help menu
|
||||
fmt.Println("HELP!")
|
||||
return nil
|
||||
case "j":
|
||||
widget.list.Next()
|
||||
widget.display()
|
||||
return nil
|
||||
case "k":
|
||||
widget.list.Prev()
|
||||
widget.display()
|
||||
return nil
|
||||
case "n":
|
||||
// Add a new item
|
||||
return nil
|
||||
}
|
||||
|
||||
switch event.Key() {
|
||||
case tcell.KeyCtrlA:
|
||||
// Move the selected item up
|
||||
widget.list.Promote()
|
||||
widget.persist()
|
||||
widget.display()
|
||||
return nil
|
||||
case tcell.KeyCtrlD:
|
||||
// Delete the selected item
|
||||
widget.list.Delete()
|
||||
widget.persist()
|
||||
widget.display()
|
||||
return nil
|
||||
case tcell.KeyCtrlZ:
|
||||
// Move the selected item down
|
||||
case tcell.KeyCtrlJ:
|
||||
// Move selected item down in the list
|
||||
widget.list.Demote()
|
||||
widget.persist()
|
||||
widget.display()
|
||||
return nil
|
||||
case tcell.KeyCtrlK:
|
||||
// Move selected item up in the list
|
||||
widget.list.Promote()
|
||||
widget.persist()
|
||||
widget.display()
|
||||
return nil
|
||||
case tcell.KeyDown:
|
||||
// Select the next item down
|
||||
widget.list.Next()
|
||||
|
Loading…
x
Reference in New Issue
Block a user