move navigation to tab updates
This commit is contained in:
parent
0c9496f087
commit
6e6b80c9b3
6
Makefile
6
Makefile
|
@ -2,9 +2,13 @@
|
|||
run-api:
|
||||
go run ./cmd/api-service/service.go -apikey localOnly
|
||||
|
||||
run-tui:
|
||||
run-tui-local:
|
||||
EMDB_BASE_URL=http://localhost:8085/ EMDB_API_KEY=hoi go run ./cmd/terminal-client/main.go
|
||||
|
||||
run-tui:
|
||||
go run ./cmd/terminal-client/main.go
|
||||
|
||||
|
||||
build-api:
|
||||
go build -o emdb-api ./cmd/api-service/service.go
|
||||
|
||||
|
|
|
@ -45,17 +45,10 @@ func (m baseModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
var cmds []tea.Cmd
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "ctrl+c", "q", "esc":
|
||||
return m, tea.Quit
|
||||
case "right", "tab":
|
||||
case NextTabSelected:
|
||||
m.tabs.Next()
|
||||
case "left", "shift+tab":
|
||||
case PrevTabSelected:
|
||||
m.tabs.Previous()
|
||||
default:
|
||||
cmds = append(cmds, m.tabs.Update(msg))
|
||||
}
|
||||
case tea.WindowSizeMsg:
|
||||
m.windowSize = msg
|
||||
if !m.initialized {
|
||||
|
|
|
@ -128,6 +128,12 @@ func (m tabEMDB) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
default:
|
||||
switch msg.String() {
|
||||
case "ctrl+c", "q", "esc":
|
||||
return m, tea.Quit
|
||||
case "right", "tab":
|
||||
cmds = append(cmds, SelectNextTab())
|
||||
case "left", "shift+tab":
|
||||
cmds = append(cmds, SelectPrevTab())
|
||||
case "up":
|
||||
m.list, cmd = m.list.Update(msg)
|
||||
cmds = append(cmds, cmd)
|
||||
|
|
|
@ -51,6 +51,12 @@ func (m tabTMDB) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
m.focused = "search"
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "ctrl+c", "q", "esc":
|
||||
return m, tea.Quit
|
||||
case "right", "tab":
|
||||
cmds = append(cmds, SelectNextTab())
|
||||
case "left", "shift+tab":
|
||||
cmds = append(cmds, SelectPrevTab())
|
||||
case "enter":
|
||||
switch m.focused {
|
||||
case "search":
|
||||
|
|
|
@ -36,6 +36,22 @@ func (l *Logger) Log(s string) { l.Lines = append(l.Lines, s) }
|
|||
|
||||
type NewMovie Movie
|
||||
|
||||
type NextTabSelected struct{}
|
||||
|
||||
func SelectNextTab() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return NextTabSelected{}
|
||||
}
|
||||
}
|
||||
|
||||
type PrevTabSelected struct{}
|
||||
|
||||
func SelectPrevTab() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return PrevTabSelected{}
|
||||
}
|
||||
}
|
||||
|
||||
func New(emdb *client.EMDB, tmdb *client.TMDB, logger *Logger) (*tea.Program, error) {
|
||||
logViewport := viewport.New(0, 0)
|
||||
logViewport.KeyMap = viewport.KeyMap{}
|
||||
|
|
Loading…
Reference in New Issue