mirror of
https://github.com/taigrr/teaqlite.git
synced 2026-04-01 20:49:05 -07:00
- Add 20+ tests for utility functions, SharedData, and Model - Tests cover: LoadTables, LoadTableData, UpdateCell, pagination, table inference, focus/blur, empty database, invalid indices - Update Go to 1.26.1, upgrade all dependencies - Replace custom Min/Max with Go builtin min/max - Format all files with goimports - Add staticcheck to CI workflow
70 lines
1.8 KiB
Go
70 lines
1.8 KiB
Go
package app
|
|
|
|
import "github.com/charmbracelet/bubbles/key"
|
|
|
|
// RowDetailKeyMap defines keybindings for the row detail view.
|
|
// Navigation follows vim-like patterns:
|
|
// - gg: go to start (requires two 'g' presses)
|
|
// - G: go to end (single 'G' press)
|
|
type RowDetailKeyMap struct {
|
|
Up key.Binding
|
|
Down key.Binding
|
|
Enter key.Binding
|
|
Escape key.Binding
|
|
Back key.Binding
|
|
GoToStart key.Binding
|
|
GoToEnd key.Binding
|
|
ToggleHelp key.Binding
|
|
}
|
|
|
|
// DefaultRowDetailKeyMap returns the default keybindings for row detail
|
|
func DefaultRowDetailKeyMap() RowDetailKeyMap {
|
|
return RowDetailKeyMap{
|
|
Up: key.NewBinding(
|
|
key.WithKeys("up", "k"),
|
|
key.WithHelp("↑/k", "up"),
|
|
),
|
|
Down: key.NewBinding(
|
|
key.WithKeys("down", "j"),
|
|
key.WithHelp("↓/j", "down"),
|
|
),
|
|
Enter: key.NewBinding(
|
|
key.WithKeys("enter"),
|
|
key.WithHelp("enter", "edit cell"),
|
|
),
|
|
Escape: key.NewBinding(
|
|
key.WithKeys("esc"),
|
|
key.WithHelp("esc", "back"),
|
|
),
|
|
Back: key.NewBinding(
|
|
key.WithKeys("q"),
|
|
key.WithHelp("q", "back"),
|
|
),
|
|
GoToStart: key.NewBinding(
|
|
key.WithKeys("g"),
|
|
key.WithHelp("gg", "go to start"),
|
|
),
|
|
GoToEnd: key.NewBinding(
|
|
key.WithKeys("G"),
|
|
key.WithHelp("G", "go to end"),
|
|
),
|
|
ToggleHelp: key.NewBinding(
|
|
key.WithKeys("ctrl+g"),
|
|
key.WithHelp("ctrl+g", "toggle help"),
|
|
),
|
|
}
|
|
}
|
|
|
|
// ShortHelp returns keybindings to be shown in the mini help view
|
|
func (k RowDetailKeyMap) ShortHelp() []key.Binding {
|
|
return []key.Binding{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd, k.Back, k.ToggleHelp}
|
|
}
|
|
|
|
// FullHelp returns keybindings for the expanded help view
|
|
func (k RowDetailKeyMap) FullHelp() [][]key.Binding {
|
|
return [][]key.Binding{
|
|
{k.Up, k.Down, k.Enter},
|
|
{k.Escape, k.Back, k.GoToStart, k.GoToEnd, k.ToggleHelp},
|
|
}
|
|
}
|