tui

package
v0.0.0-...-4301a79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAIProvider

func NewAIProvider(provider, apiKey, model string) (ai.Provider, error)

NewAIProvider is a helper to create AI providers

func SectionConnections

func SectionConnections() components.SidebarSection

Helper to get SectionConnections

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App represents the SQDesk TUI application

func New

func New() (*App, error)

New creates a new SQDesk application

func (*App) Close

func (a *App) Close() error

Close cleans up resources

func (*App) Run

func (a *App) Run() error

Run starts the TUI application

type AppState

type AppState int

AppState represents the application state

const (
	StateSetup AppState = iota
	StateNormal
	StateAIPrompt
	StateSettings
	StateConnModal
)

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the main application model

func NewModel

func NewModel(cfg *config.Config) *Model

NewModel creates a new application model

func (*Model) Close

func (m *Model) Close() error

Close cleans up resources

func (*Model) Connect

func (m *Model) Connect() error

Connect connects to the active database

func (*Model) Disconnect

func (m *Model) Disconnect()

Disconnect disconnects from the current database

func (*Model) ExecuteQuery

func (m *Model) ExecuteQuery()

ExecuteQuery executes the current SQL query

func (*Model) FocusEditor

func (m *Model) FocusEditor()

FocusEditor focuses the editor pane

func (*Model) FocusNext

func (m *Model) FocusNext()

FocusNext moves focus to the next pane

func (*Model) FocusPrev

func (m *Model) FocusPrev()

FocusPrev moves focus to the previous pane

func (*Model) GenerateSQL

func (m *Model) GenerateSQL(prompt string)

GenerateSQL uses AI to generate SQL from natural language

func (*Model) GetAIInfo

func (m *Model) GetAIInfo() string

GetAIInfo returns the AI provider info string

func (*Model) GetConnectionInfo

func (m *Model) GetConnectionInfo() string

GetConnectionInfo returns the current connection info string

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init initializes the model

func (*Model) LoadDatabases

func (m *Model) LoadDatabases()

LoadDatabases loads the list of available databases

func (*Model) PreviewTable

func (m *Model) PreviewTable(tableName string)

PreviewTable previews the selected table

func (*Model) RefactorSQL

func (m *Model) RefactorSQL(instruction string)

RefactorSQL uses AI to refactor SQL

func (*Model) RestoreLastState

func (m *Model) RestoreLastState()

RestoreLastState restores the last database and table selection

func (*Model) SwitchDatabase

func (m *Model) SwitchDatabase(dbName string) error

SwitchDatabase switches to a different database

func (*Model) TestConnection

func (m *Model) TestConnection(cfg *config.DatabaseConfig) error

TestConnection tests a database connection without storing it

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles all input and state changes

func (*Model) UpdateTheme

func (m *Model) UpdateTheme(themeName string)

UpdateTheme updates the theme and regenerates styles

func (*Model) View

func (m *Model) View() string

View renders the entire application

type Pane

type Pane int

Pane represents the focused pane

const (
	PaneSidebar Pane = iota
	PaneEditor
	PaneResults
)

type Styles

type Styles struct {
	// App styles
	App    lipgloss.Style
	Header lipgloss.Style
	Footer lipgloss.Style

	// Panel styles
	Panel        lipgloss.Style
	PanelFocused lipgloss.Style
	PanelTitle   lipgloss.Style

	// Sidebar styles
	Sidebar         lipgloss.Style
	SidebarItem     lipgloss.Style
	SidebarSelected lipgloss.Style
	ActiveConn      lipgloss.Style
	InactiveConn    lipgloss.Style
	AddButton       lipgloss.Style

	// Editor styles
	Editor       lipgloss.Style
	EditorCursor lipgloss.Style
	GhostText    lipgloss.Style

	// Results table styles
	ResultsHeader lipgloss.Style
	ResultsCell   lipgloss.Style
	ResultsRow    lipgloss.Style

	// Status bar styles
	StatusBar   lipgloss.Style
	StatusItem  lipgloss.Style
	StatusError lipgloss.Style

	// Modal styles
	Modal        lipgloss.Style
	ModalTitle   lipgloss.Style
	ModalContent lipgloss.Style

	// Input styles
	Input        lipgloss.Style
	InputFocused lipgloss.Style
	InputLabel   lipgloss.Style

	// Button styles
	Button         lipgloss.Style
	ButtonActive   lipgloss.Style
	ButtonDisabled lipgloss.Style

	// Syntax highlighting
	Keyword  lipgloss.Style
	String   lipgloss.Style
	Number   lipgloss.Style
	Comment  lipgloss.Style
	Function lipgloss.Style

	// Messages
	ErrorText   lipgloss.Style
	SuccessText lipgloss.Style
	InfoText    lipgloss.Style
	WarningText lipgloss.Style

	// Help
	HelpKey  lipgloss.Style
	HelpDesc lipgloss.Style
}

Styles holds all TUI styles

func NewStyles

func NewStyles(colors ThemeColors) *Styles

NewStyles creates styles based on theme colors

type ThemeColors

type ThemeColors struct {
	Primary         lipgloss.Color
	Secondary       lipgloss.Color
	Accent          lipgloss.Color
	Background      lipgloss.Color
	BackgroundDark  lipgloss.Color
	BackgroundLight lipgloss.Color
	Text            lipgloss.Color
	TextMuted       lipgloss.Color
	TextBright      lipgloss.Color
	Success         lipgloss.Color
	Warning         lipgloss.Color
	Error           lipgloss.Color
	Info            lipgloss.Color
	Border          lipgloss.Color
	BorderFocus     lipgloss.Color
	Selection       lipgloss.Color
	GhostText       lipgloss.Color
}

ThemeColors holds the color palette

func GetDefaultColors

func GetDefaultColors() ThemeColors

GetDefaultColors returns default theme colors

func GetDraculaColors

func GetDraculaColors() ThemeColors

GetDraculaColors returns Dracula theme colors

func GetNordColors

func GetNordColors() ThemeColors

GetNordColors returns Nord theme colors

func GetThemeColors

func GetThemeColors(themeName string) ThemeColors

GetThemeColors returns colors for the specified theme

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL