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