Documentation
¶
Overview ¶
Package app provides the main application logic for the sqlite browser.
Index ¶
- Constants
- Variables
- func Max(a, b int) int
- func Min(a, b int) int
- func TruncateString(s string, maxLen int) string
- func WrapText(text string, width int) []string
- type AppKeyMap
- type EditCellKeyMap
- type EditCellModel
- type EditCellOption
- type ExecuteQueryMsg
- type Model
- type Option
- type QueryCompletedMsg
- type QueryKeyMap
- type QueryModel
- type QueryOption
- type RefreshDataMsg
- type ReturnToQueryMsg
- type RowDetailKeyMap
- type RowDetailModel
- type RowDetailOption
- type SharedData
- type SwitchToEditCellMsg
- type SwitchToQueryMsg
- type SwitchToRowDetailFromQueryMsg
- type SwitchToRowDetailMsg
- type SwitchToTableDataMsg
- type SwitchToTableListClearMsg
- type SwitchToTableListMsg
- type TableDataKeyMap
- type TableDataModel
- type TableDataOption
- type TableListKeyMap
- type TableListModel
- type TableListOption
- type ToggleHelpMsg
- type UpdateCellMsg
Constants ¶
const (
PageSize = 20
)
Variables ¶
var ( TitleStyle = lipgloss.NewStyle(). Bold(true). Foreground(lipgloss.Color("#FAFAFA")). Background(lipgloss.Color("#7D56F4")). Padding(0, 1) SelectedStyle = lipgloss.NewStyle(). Bold(true). Foreground(lipgloss.Color("#FAFAFA")). Background(lipgloss.Color("#F25D94")) NormalStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("#FAFAFA")) ErrorStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("#FF0000")). Bold(true) HelpStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("#626262")) )
Styles
Functions ¶
func TruncateString ¶
Types ¶
type AppKeyMap ¶
AppKeyMap defines the keybindings for the application
func DefaultAppKeyMap ¶
func DefaultAppKeyMap() AppKeyMap
DefaultAppKeyMap returns the default keybindings
type EditCellKeyMap ¶
type EditCellKeyMap struct {
Save key.Binding
Cancel key.Binding
CursorLeft key.Binding
CursorRight key.Binding
WordLeft key.Binding
WordRight key.Binding
LineStart key.Binding
LineEnd key.Binding
DeleteWord key.Binding
DeleteChar key.Binding
ToggleHelp key.Binding
}
EditCellKeyMap defines keybindings for the edit cell view
func DefaultEditCellKeyMap ¶
func DefaultEditCellKeyMap() EditCellKeyMap
DefaultEditCellKeyMap returns the default keybindings for edit cell
func (EditCellKeyMap) FullHelp ¶
func (k EditCellKeyMap) FullHelp() [][]key.Binding
FullHelp returns keybindings for the expanded help view
func (EditCellKeyMap) ShortHelp ¶
func (k EditCellKeyMap) ShortHelp() []key.Binding
ShortHelp returns keybindings to be shown in the mini help view
type EditCellModel ¶
type EditCellModel struct {
// contains filtered or unexported fields
}
func NewEditCellModel ¶
func NewEditCellModel(shared *SharedData, rowIndex, colIndex int, opts ...EditCellOption) *EditCellModel
func (EditCellModel) Focused ¶
func (m EditCellModel) Focused() bool
Focused returns the focus state
func (*EditCellModel) Init ¶
func (m *EditCellModel) Init() tea.Cmd
func (*EditCellModel) View ¶
func (m *EditCellModel) View() string
type EditCellOption ¶
type EditCellOption func(*EditCellModel)
EditCellOption is a functional option for configuring EditCellModel
func WithEditCellKeyMap ¶
func WithEditCellKeyMap(km EditCellKeyMap) EditCellOption
WithEditCellKeyMap sets the key map
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the main application model
type Option ¶
type Option func(*Model)
Option is a functional option for configuring the Model
func WithDimensions ¶
WithDimensions sets the initial dimensions
func WithKeyMap ¶
WithKeyMap sets the key map for the application
type QueryCompletedMsg ¶
Custom message types
type QueryKeyMap ¶
type QueryKeyMap struct {
// Input mode keys
Execute key.Binding
Escape key.Binding
CursorLeft key.Binding
CursorRight key.Binding
WordLeft key.Binding
WordRight key.Binding
LineStart key.Binding
LineEnd key.Binding
DeleteWord key.Binding
// Results mode keys
Up key.Binding
Down key.Binding
Enter key.Binding
EditQuery key.Binding
GoToStart key.Binding
GoToEnd key.Binding
Back key.Binding
ToggleHelp key.Binding
}
QueryKeyMap defines keybindings for the query view. Navigation follows vim-like patterns: - gg: go to start (requires two 'g' presses) - G: go to end (single 'G' press)
func DefaultQueryKeyMap ¶
func DefaultQueryKeyMap() QueryKeyMap
DefaultQueryKeyMap returns the default keybindings for query view
func (QueryKeyMap) FullHelp ¶
func (k QueryKeyMap) FullHelp() [][]key.Binding
FullHelp returns keybindings for the expanded help view
func (QueryKeyMap) ShortHelp ¶
func (k QueryKeyMap) ShortHelp() []key.Binding
ShortHelp returns keybindings to be shown in the mini help view
type QueryModel ¶
type QueryModel struct {
FocusOnInput bool
// contains filtered or unexported fields
}
func NewQueryModel ¶
func NewQueryModel(shared *SharedData, opts ...QueryOption) *QueryModel
func (*QueryModel) Init ¶
func (m *QueryModel) Init() tea.Cmd
func (*QueryModel) View ¶
func (m *QueryModel) View() string
type QueryOption ¶
type QueryOption func(*QueryModel)
QueryOption is a functional option for configuring QueryModel
func WithQueryKeyMap ¶
func WithQueryKeyMap(km QueryKeyMap) QueryOption
WithQueryKeyMap sets the key map
type ReturnToQueryMsg ¶
type ReturnToQueryMsg struct{} // Return to query mode from row detail
Custom message types
type RowDetailKeyMap ¶
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
}
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)
func DefaultRowDetailKeyMap ¶
func DefaultRowDetailKeyMap() RowDetailKeyMap
DefaultRowDetailKeyMap returns the default keybindings for row detail
func (RowDetailKeyMap) FullHelp ¶
func (k RowDetailKeyMap) FullHelp() [][]key.Binding
FullHelp returns keybindings for the expanded help view
func (RowDetailKeyMap) ShortHelp ¶
func (k RowDetailKeyMap) ShortHelp() []key.Binding
ShortHelp returns keybindings to be shown in the mini help view
type RowDetailModel ¶
type RowDetailModel struct {
FromQuery bool
// contains filtered or unexported fields
}
func NewRowDetailModel ¶
func NewRowDetailModel(shared *SharedData, rowIndex int, opts ...RowDetailOption) *RowDetailModel
func (RowDetailModel) Focused ¶
func (m RowDetailModel) Focused() bool
Focused returns the focus state
func (*RowDetailModel) Init ¶
func (m *RowDetailModel) Init() tea.Cmd
func (*RowDetailModel) View ¶
func (m *RowDetailModel) View() string
type RowDetailOption ¶
type RowDetailOption func(*RowDetailModel)
RowDetailOption is a functional option for configuring RowDetailModel
func WithRowDetailKeyMap ¶
func WithRowDetailKeyMap(km RowDetailKeyMap) RowDetailOption
WithRowDetailKeyMap sets the key map
type SharedData ¶
type SharedData struct {
// Query result context
}
SharedData that all models need access to
func NewSharedData ¶
func NewSharedData(db *sql.DB) *SharedData
func (*SharedData) LoadTableData ¶
func (s *SharedData) LoadTableData() error
func (*SharedData) LoadTables ¶
func (s *SharedData) LoadTables() error
func (*SharedData) UpdateCell ¶
func (s *SharedData) UpdateCell(rowIndex, colIndex int, newValue string) error
type SwitchToEditCellMsg ¶
type SwitchToEditCellMsg struct{ RowIndex, ColIndex int }
Custom message types
type SwitchToRowDetailFromQueryMsg ¶
type SwitchToRowDetailFromQueryMsg struct{ RowIndex int }
Custom message types
type SwitchToTableListClearMsg ¶
type SwitchToTableListClearMsg struct{} // Switch to table list and clear any filter
Custom message types
type TableDataKeyMap ¶
type TableDataKeyMap struct {
Up key.Binding
Down key.Binding
Left key.Binding
Right key.Binding
Enter key.Binding
Search key.Binding
Escape key.Binding
Back key.Binding
GoToStart key.Binding
GoToEnd key.Binding
Refresh key.Binding
SQLMode key.Binding
ToggleHelp key.Binding
}
TableDataKeyMap defines keybindings for the table data view. Navigation follows vim-like patterns: - gg: go to start (requires two 'g' presses) - G: go to end (single 'G' press)
func DefaultTableDataKeyMap ¶
func DefaultTableDataKeyMap() TableDataKeyMap
DefaultTableDataKeyMap returns the default keybindings for table data
func (TableDataKeyMap) FullHelp ¶
func (k TableDataKeyMap) FullHelp() [][]key.Binding
FullHelp returns keybindings for the expanded help view
func (TableDataKeyMap) ShortHelp ¶
func (k TableDataKeyMap) ShortHelp() []key.Binding
ShortHelp returns keybindings to be shown in the mini help view
type TableDataModel ¶
type TableDataModel struct {
// contains filtered or unexported fields
}
func NewTableDataModel ¶
func NewTableDataModel(shared *SharedData, opts ...TableDataOption) *TableDataModel
func (TableDataModel) Focused ¶
func (m TableDataModel) Focused() bool
Focused returns the focus state
func (*TableDataModel) Init ¶
func (m *TableDataModel) Init() tea.Cmd
func (*TableDataModel) View ¶
func (m *TableDataModel) View() string
type TableDataOption ¶
type TableDataOption func(*TableDataModel)
TableDataOption is a functional option for configuring TableDataModel
func WithTableDataKeyMap ¶
func WithTableDataKeyMap(km TableDataKeyMap) TableDataOption
WithTableDataKeyMap sets the key map
type TableListKeyMap ¶
type TableListKeyMap struct {
Up key.Binding
Down key.Binding
Left key.Binding
Right key.Binding
Enter key.Binding
Search key.Binding
Escape key.Binding
GoToStart key.Binding
GoToEnd key.Binding
Refresh key.Binding
SQLMode key.Binding
ToggleHelp key.Binding
}
TableListKeyMap defines keybindings for the table list view. Navigation follows vim-like patterns: - gg: go to start (requires two 'g' presses) - G: go to end (single 'G' press)
func DefaultTableListKeyMap ¶
func DefaultTableListKeyMap() TableListKeyMap
DefaultTableListKeyMap returns the default keybindings for table list
func (TableListKeyMap) FullHelp ¶
func (k TableListKeyMap) FullHelp() [][]key.Binding
FullHelp returns keybindings for the expanded help view
func (TableListKeyMap) ShortHelp ¶
func (k TableListKeyMap) ShortHelp() []key.Binding
ShortHelp returns keybindings to be shown in the mini help view
type TableListModel ¶
type TableListModel struct {
// contains filtered or unexported fields
}
func NewTableListModel ¶
func NewTableListModel(shared *SharedData, opts ...TableListOption) *TableListModel
func (TableListModel) Focused ¶
func (m TableListModel) Focused() bool
Focused returns the focus state
func (*TableListModel) Init ¶
func (m *TableListModel) Init() tea.Cmd
func (*TableListModel) View ¶
func (m *TableListModel) View() string
type TableListOption ¶
type TableListOption func(*TableListModel)
TableListOption is a functional option for configuring TableListModel
func WithTableListKeyMap ¶
func WithTableListKeyMap(km TableListKeyMap) TableListOption
WithTableListKeyMap sets the key map
type ToggleHelpMsg ¶
type ToggleHelpMsg struct{} // Toggle between short and full help
Custom message types
type UpdateCellMsg ¶
Custom message types