more keybinds, management menu

trunk
nbsp 2025-01-05 22:58:43 +02:00
parent 6233024235
commit 07f15d1701
No known key found for this signature in database
GPG Key ID: 7184AC1C9835CE48
4 changed files with 78 additions and 11 deletions

View File

@ -30,7 +30,7 @@ func (credits *Credits) Event(state *ui.State, event vaxis.Event) (processed boo
switch key.String() { switch key.String() {
case "Ctrl+c", "Ctrl+d": case "Ctrl+c", "Ctrl+d":
close(ui.Quit) close(ui.Quit)
case "Enter", "q": case "Enter", "q", "h", "l", "Left", "Right":
ui.ViewChange <- NewMainMenu() ui.ViewChange <- NewMainMenu()
} }
processed = true processed = true

65
app/management.go 100644
View File

@ -0,0 +1,65 @@
package app
import (
"git.sr.ht/~rockorager/vaxis"
"git.sr.ht/~rockorager/vaxis/widgets/list"
"git.tilde.town/nbsp/neofeels/ui"
)
type Management struct {
title string
list list.List
help string
}
func NewManagement() *Management {
return &Management{
title,
list.New([]string{
" read over feels ", // TODO
" modify feels publishing ", // TODO
" backup your feels ", // TODO
" import a feels backup ", // TODO
" bury some feels ", // TODO
" delete feels by day ", // TODO
" purge all feels ", // TODO
" wipe feels account ", // TODO
}),
"↑↓/kj move ↵ enter q return",
}
}
func (management *Management) Event(state *ui.State, event vaxis.Event) (processed bool) {
if key, ok := event.(vaxis.Key); ok && key.EventType == vaxis.EventPress {
switch key.String() {
case "Ctrl+c", "Ctrl+d":
close(ui.Quit)
case "Down", "j":
management.list.Down()
case "Up", "k":
management.list.Up()
case "End", "Shift+g":
management.list.End()
case "Home", "g":
management.list.Home()
case "q", "h", "Left":
ui.ViewChange <- NewMainMenu()
case "Enter", "l", "Right":
switch management.list.Index() {
}
}
processed = true
}
win := state.Window()
win.New(win.Width/2-10, win.Height/2-8, 20, 5).Print(vaxis.Segment{Text: management.title})
management.list.Draw(vaxis.Window{
Vx: win.Vx,
Parent: nil,
Column: win.Width/2 - 14,
Row: win.Height/2 - 2,
Width: 28,
Height: 10,
})
win.New(win.Width/2-14, win.Height/2+7, 28, 1).Print(vaxis.Segment{Text: management.help})
return
}

View File

@ -30,12 +30,12 @@ func NewMainMenu() *MainMenu {
list.New([]string{ list.New([]string{
" record some feels ", " record some feels ",
" manage your feels ", " manage your feels ",
" check out your neighbors ", " check out your neighbors ", // TODO
" browse global feels ", " browse global feels ", // TODO
" visit your subscriptions ", " visit your subscriptions ", // TODO
" scribble some graffiti ", " scribble some graffiti ", // TODO
" change your settings ", " change your settings ", // TODO
" send some feedback ", " send some feedback ", // TODO
" see credits ", " see credits ",
" read documentation ", " read documentation ",
}), }),
@ -52,14 +52,16 @@ func (menu *MainMenu) Event(state *ui.State, event vaxis.Event) (processed bool)
menu.list.Down() menu.list.Down()
case "Up", "k": case "Up", "k":
menu.list.Up() menu.list.Up()
case "End": case "End", "Shift+g":
menu.list.End() menu.list.End()
case "Home": case "Home", "g":
menu.list.Home() menu.list.Home()
case "Enter": case "Enter", "l", "Right":
switch menu.list.Index() { switch menu.list.Index() {
case 0: case 0:
newFeels(state) newFeels(state)
case 1:
ui.ViewChange <- NewManagement()
case 8: case 8:
ui.ViewChange <- NewCredits() ui.ViewChange <- NewCredits()
case 9: case 9:

View File

@ -37,7 +37,7 @@ func (posted *Posted) Event(state *ui.State, event vaxis.Event) (processed bool)
switch key.String() { switch key.String() {
case "Ctrl+c", "Ctrl+d": case "Ctrl+c", "Ctrl+d":
close(ui.Quit) close(ui.Quit)
case "Enter", "q": case "Enter", "q", "h", "l", "Left", "Right":
ui.ViewChange <- NewMainMenu() ui.ViewChange <- NewMainMenu()
} }
processed = true processed = true