components

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: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIPrompt

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

AIPrompt component for AI input modal

func NewAIPrompt

func NewAIPrompt(styles AIPromptStyles) AIPrompt

NewAIPrompt creates a new AI prompt component

func (*AIPrompt) ClearContext

func (a *AIPrompt) ClearContext()

ClearContext clears the context

func (AIPrompt) GetMode

func (a AIPrompt) GetMode() AIPromptMode

GetMode returns the current mode

func (AIPrompt) GetValue

func (a AIPrompt) GetValue() string

GetValue returns the input value

func (*AIPrompt) Hide

func (a *AIPrompt) Hide()

Hide hides the AI prompt modal

func (AIPrompt) IsVisible

func (a AIPrompt) IsVisible() bool

IsVisible returns if the prompt is visible

func (*AIPrompt) SetContext

func (a *AIPrompt) SetContext(text string)

SetContext sets the selected text context

func (*AIPrompt) SetSize

func (a *AIPrompt) SetSize(width, height int)

SetSize sets the prompt dimensions

func (*AIPrompt) Show

func (a *AIPrompt) Show(mode AIPromptMode)

Show shows the AI prompt modal

func (AIPrompt) Update

func (a AIPrompt) Update(msg tea.Msg) (AIPrompt, tea.Cmd)

Update handles input for the AI prompt

func (AIPrompt) View

func (a AIPrompt) View() string

View renders the AI prompt

type AIPromptMode

type AIPromptMode int

AIPromptMode indicates the type of AI operation

const (
	AIPromptModeNL2SQL AIPromptMode = iota
	AIPromptModeRefactor
)

type AIPromptStyles

type AIPromptStyles struct {
	Modal        lipgloss.Style
	Title        lipgloss.Style
	Input        lipgloss.Style
	Hint         lipgloss.Style
	ModeNL2SQL   lipgloss.Style
	ModeRefactor lipgloss.Style
}

AIPromptStyles holds styling for the AI prompt

type AddConnectionItem

type AddConnectionItem struct{}

AddConnectionItem represents the add button

func (AddConnectionItem) Description

func (a AddConnectionItem) Description() string

func (AddConnectionItem) FilterValue

func (a AddConnectionItem) FilterValue() string

func (AddConnectionItem) Title

func (a AddConnectionItem) Title() string

type CompletionPopup

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

CompletionPopup shows completion suggestions

func NewCompletionPopup

func NewCompletionPopup(styles CompletionStyles) CompletionPopup

NewCompletionPopup creates a new completion popup

func (CompletionPopup) GetPosition

func (c CompletionPopup) GetPosition() (int, int)

GetPosition returns the popup position

func (CompletionPopup) GetSelected

func (c CompletionPopup) GetSelected() *completion.CompletionItem

GetSelected returns the selected item

func (*CompletionPopup) Hide

func (c *CompletionPopup) Hide()

Hide hides the popup

func (CompletionPopup) IsVisible

func (c CompletionPopup) IsVisible() bool

IsVisible returns if popup is visible

func (*CompletionPopup) MoveDown

func (c *CompletionPopup) MoveDown()

MoveDown moves selection down

func (*CompletionPopup) MoveUp

func (c *CompletionPopup) MoveUp()

MoveUp moves selection up

func (*CompletionPopup) SetPosition

func (c *CompletionPopup) SetPosition(x, y int)

SetPosition sets the popup position

func (*CompletionPopup) SetWidth

func (c *CompletionPopup) SetWidth(w int)

SetWidth sets the popup width

func (*CompletionPopup) Show

func (c *CompletionPopup) Show(items []completion.CompletionItem, x, y int)

Show displays the popup with items

func (CompletionPopup) Update

func (c CompletionPopup) Update(msg tea.Msg) (CompletionPopup, tea.Cmd)

Update handles input

func (CompletionPopup) View

func (c CompletionPopup) View() string

View renders the popup

type CompletionStyles

type CompletionStyles struct {
	Border   lipgloss.Style
	Item     lipgloss.Style
	Selected lipgloss.Style
	Kind     lipgloss.Style
	Detail   lipgloss.Style
}

CompletionStyles holds styling for the popup

type ConnectionAction

type ConnectionAction int

ConnectionAction represents the action selected in the modal

const (
	ActionNone ConnectionAction = iota
	ActionConnect
	ActionEdit
	ActionDelete
	ActionCancel
)

type ConnectionItem

type ConnectionItem struct {
	Name   string
	Driver string
	Active bool
}

ConnectionItem represents a connection in the sidebar

func (ConnectionItem) Description

func (c ConnectionItem) Description() string

func (ConnectionItem) FilterValue

func (c ConnectionItem) FilterValue() string

func (ConnectionItem) Title

func (c ConnectionItem) Title() string

type ConnectionModal

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

ConnectionModal component for connection actions pop-up

func NewConnectionModal

func NewConnectionModal(styles ConnectionModalStyles) ConnectionModal

NewConnectionModal creates a new connection modal

func (ConnectionModal) GetConnectionIndex

func (m ConnectionModal) GetConnectionIndex() int

GetConnectionIndex returns the connection index

func (ConnectionModal) GetSelectedAction

func (m ConnectionModal) GetSelectedAction() ConnectionAction

GetSelectedAction returns the selected action

func (*ConnectionModal) Hide

func (m *ConnectionModal) Hide()

Hide hides the modal

func (ConnectionModal) IsVisible

func (m ConnectionModal) IsVisible() bool

IsVisible returns if modal is visible

func (*ConnectionModal) MoveDown

func (m *ConnectionModal) MoveDown()

MoveDown moves selection down

func (*ConnectionModal) MoveUp

func (m *ConnectionModal) MoveUp()

MoveUp moves selection up

func (*ConnectionModal) SetSize

func (m *ConnectionModal) SetSize(width, height int)

SetSize sets the modal dimensions

func (*ConnectionModal) SetStatus

func (m *ConnectionModal) SetStatus(msg string, isError bool)

SetStatus sets the status message

func (*ConnectionModal) Show

func (m *ConnectionModal) Show(connName string, connIndex int)

Show shows the modal for a connection

func (ConnectionModal) View

func (m ConnectionModal) View() string

View renders the modal

type ConnectionModalStyles

type ConnectionModalStyles struct {
	Modal    lipgloss.Style
	Title    lipgloss.Style
	Item     lipgloss.Style
	Selected lipgloss.Style
	Hint     lipgloss.Style
	Success  lipgloss.Style
	Error    lipgloss.Style
}

ConnectionModalStyles holds styling for the modal

type DatabaseItem

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

DatabaseItem represents a database in the sidebar

func (DatabaseItem) Description

func (d DatabaseItem) Description() string

func (DatabaseItem) FilterValue

func (d DatabaseItem) FilterValue() string

func (DatabaseItem) Title

func (d DatabaseItem) Title() string

type Editor

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

Editor component for SQL editing (Sublime-like)

func NewEditor

func NewEditor(styles EditorStyles) Editor

NewEditor creates a new editor component

func (Editor) GetCursorPosition

func (e Editor) GetCursorPosition() int

GetCursorPosition returns the cursor position as character offset

func (Editor) GetSelectedText

func (e Editor) GetSelectedText() string

GetSelectedText returns the text to execute

func (Editor) GetValue

func (e Editor) GetValue() string

GetValue returns the current SQL text

func (Editor) HighlightSQL

func (e Editor) HighlightSQL(sql string) string

HighlightSQL applies basic syntax highlighting to SQL

func (*Editor) InsertText

func (e *Editor) InsertText(text string)

InsertText inserts text at the current cursor position

func (Editor) IsFocused

func (e Editor) IsFocused() bool

IsFocused returns if editor is focused

func (*Editor) ReplaceCurrentWord

func (e *Editor) ReplaceCurrentWord(text string)

ReplaceCurrentWord replaces the word being typed with the given text

func (*Editor) SetFocused

func (e *Editor) SetFocused(focused bool)

SetFocused sets the focus state

func (*Editor) SetKeyMap

func (e *Editor) SetKeyMap(km config.KeyMap)

SetKeyMap sets the editor keymap

func (*Editor) SetPosition

func (e *Editor) SetPosition(x, y int)

SetPosition sets the absolute position of the editor

func (*Editor) SetSchema

func (e *Editor) SetSchema(schema map[string][]string)

SetSchema sets the database schema for suggestions

func (*Editor) SetSize

func (e *Editor) SetSize(width, height int)

SetSize sets the editor dimensions

func (*Editor) SetValue

func (e *Editor) SetValue(value string)

SetValue sets the SQL text

func (Editor) Update

func (e Editor) Update(msg tea.Msg) (Editor, tea.Cmd)

Update handles input for the editor

func (Editor) View

func (e Editor) View() string

View renders the editor

type EditorMode

type EditorMode int

EditorMode represents the current mode of the editor

const (
	ModeNormal EditorMode = iota
	ModeInsert
	ModeVisual
)

type EditorState

type EditorState struct {
	Text   string
	Cursor int
}

EditorState represents a snapshot of the editor

type EditorStyles

type EditorStyles struct {
	Normal     lipgloss.Style
	Focused    lipgloss.Style
	Title      lipgloss.Style
	LineNum    lipgloss.Style
	Keyword    lipgloss.Style
	String     lipgloss.Style
	GhostText  lipgloss.Style
	Selection  lipgloss.Style
	Suggestion lipgloss.Style
	Type       lipgloss.Style
	Function   lipgloss.Style
	Operator   lipgloss.Style
	Mode       lipgloss.Style
}

EditorStyles holds styling for the editor

type Help

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

Help component for displaying shortcuts

func NewHelp

func NewHelp(styles HelpStyles) Help

NewHelp creates a new Help component

func (*Help) Hide

func (h *Help) Hide()

Hide hides the help modal

func (Help) IsVisible

func (h Help) IsVisible() bool

IsVisible returns if help is visible

func (*Help) NextPage

func (h *Help) NextPage()

NextPage moves to next page

func (*Help) PrevPage

func (h *Help) PrevPage()

PrevPage moves to previous page

func (*Help) SetSize

func (h *Help) SetSize(width, height int)

SetSize sets the help modal size

func (*Help) Show

func (h *Help) Show()

Show displays the help modal

func (*Help) Toggle

func (h *Help) Toggle()

Toggle toggles the help modal visibility

func (Help) Update

func (h Help) Update(msg tea.Msg) (Help, tea.Cmd)

Update handles input

func (Help) View

func (h Help) View() string

View renders the help modal

type HelpStyles

type HelpStyles struct {
	Modal    lipgloss.Style
	Title    lipgloss.Style
	Category lipgloss.Style
	Key      lipgloss.Style
	Desc     lipgloss.Style
	Footer   lipgloss.Style
}

HelpStyles holds styling for the help modal

type Position

type Position struct {
	Line, Col int
}

Position represents a cursor position

type Results

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

Results component for displaying query results

func NewResults

func NewResults(styles ResultsStyles) Results

NewResults creates a new results component

func (*Results) Clear

func (r *Results) Clear()

Clear clears the results

func (Results) CopyAllData

func (r Results) CopyAllData() error

CopyAllData copies all data to clipboard as TSV

func (Results) CopySelectedRow

func (r Results) CopySelectedRow() error

CopySelectedRow copies the selected row data to clipboard

func (Results) GetRowCount

func (r Results) GetRowCount() int

GetRowCount returns the number of rows

func (Results) GetViewMode

func (r Results) GetViewMode() ViewMode

GetViewMode returns the current view mode

func (Results) IsFocused

func (r Results) IsFocused() bool

IsFocused returns if results is focused

func (*Results) NextPage

func (r *Results) NextPage()

NextPage moves to the next page

func (*Results) PrevPage

func (r *Results) PrevPage()

PrevPage moves to the previous page

func (*Results) SetData

func (r *Results) SetData(columns []string, rows []map[string]interface{})

SetData sets the query results data

func (*Results) SetError

func (r *Results) SetError(err error)

SetError sets an error message

func (*Results) SetFocused

func (r *Results) SetFocused(focused bool)

SetFocused sets the focus state

func (*Results) SetMessage

func (r *Results) SetMessage(msg string)

SetMessage sets an info message

func (*Results) SetSize

func (r *Results) SetSize(width, height int)

SetSize sets the results dimensions

func (*Results) SetViewMode

func (r *Results) SetViewMode(mode ViewMode)

SetViewMode sets the current view mode

func (Results) Update

func (r Results) Update(msg tea.Msg) (Results, tea.Cmd)

Update handles input for the results

func (Results) View

func (r Results) View() string

View renders the results

type ResultsStyles

type ResultsStyles struct {
	Normal      lipgloss.Style
	Focused     lipgloss.Style
	Title       lipgloss.Style
	Header      lipgloss.Style
	Cell        lipgloss.Style
	SelectedRow lipgloss.Style
	Error       lipgloss.Style
	Info        lipgloss.Style
}

ResultsStyles holds styling for the results

type Settings

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

Settings component for settings modal

func NewSettings

func NewSettings(styles SettingsStyles) Settings

NewSettings creates a new settings component

func (*Settings) ClearConnection

func (s *Settings) ClearConnection()

ClearConnection clears all connection form fields (for new connection)

func (*Settings) ClearStatus

func (s *Settings) ClearStatus()

ClearStatus clears the status message

func (Settings) GetAPIKey

func (s Settings) GetAPIKey() string

GetAPIKey returns the API key

func (Settings) GetConnectionConfig

func (s Settings) GetConnectionConfig() (name, driver, host, port, user, pass, db string)

GetConnectionConfig returns the connection configuration

func (Settings) GetEditingConnIndex

func (s Settings) GetEditingConnIndex() int

GetEditingConnIndex returns the index of connection being edited (-1 if new)

func (Settings) GetModel

func (s Settings) GetModel() string

GetModel returns the AI model

func (Settings) GetSelectedProvider

func (s Settings) GetSelectedProvider() string

GetSelectedProvider returns the selected AI provider

func (Settings) GetSelectedTheme

func (s Settings) GetSelectedTheme() string

GetSelectedTheme returns the selected theme name

func (Settings) GetStatus

func (s Settings) GetStatus() (string, bool)

GetStatus returns the current status

func (*Settings) Hide

func (s *Settings) Hide()

Hide hides the settings modal

func (Settings) IsEditingConnection

func (s Settings) IsEditingConnection() bool

IsEditingConnection returns true if editing existing connection

func (Settings) IsVisible

func (s Settings) IsVisible() bool

IsVisible returns if settings is visible

func (*Settings) LoadConnection

func (s *Settings) LoadConnection(name, driver, host string, port int, user, pass, database string, editIndex int)

LoadConnection loads connection data into the form for editing

func (*Settings) NextTab

func (s *Settings) NextTab()

NextTab moves to the next tab

func (*Settings) PrevTab

func (s *Settings) PrevTab()

PrevTab moves to the previous tab

func (*Settings) SetAIProvider

func (s *Settings) SetAIProvider(provider string)

SetAIProvider sets the AI provider

func (*Settings) SetAPIKey

func (s *Settings) SetAPIKey(key string)

SetAPIKey sets the API key

func (*Settings) SetModel

func (s *Settings) SetModel(model string)

SetModel sets the AI model

func (*Settings) SetSize

func (s *Settings) SetSize(width, height int)

SetSize sets the settings dimensions

func (*Settings) SetStatus

func (s *Settings) SetStatus(msg string, isError bool)

SetStatus sets the status message

func (*Settings) SetTheme

func (s *Settings) SetTheme(theme string)

SetTheme sets the current theme index

func (*Settings) Show

func (s *Settings) Show()

Show shows the settings modal

func (*Settings) ShowForConnection

func (s *Settings) ShowForConnection()

ShowForConnection shows settings modal and switches to Connections tab

func (Settings) Update

func (s Settings) Update(msg tea.Msg) (Settings, tea.Cmd)

Update handles input for settings

func (Settings) View

func (s Settings) View() string

View renders the settings modal

type SettingsStyles

type SettingsStyles struct {
	Modal        lipgloss.Style
	Title        lipgloss.Style
	Tab          lipgloss.Style
	TabActive    lipgloss.Style
	Label        lipgloss.Style
	Input        lipgloss.Style
	InputFocus   lipgloss.Style
	Button       lipgloss.Style
	ButtonActive lipgloss.Style
	Selected     lipgloss.Style
	Hint         lipgloss.Style
	Success      lipgloss.Style
	Error        lipgloss.Style
}

SettingsStyles holds styling for the settings

type SettingsTab

type SettingsTab int

SettingsTab represents a tab in settings

const (
	SettingsTabTheme SettingsTab = iota
	SettingsTabAI
	SettingsTabConnections
)

type ShortcutCategory

type ShortcutCategory struct {
	Name  string
	Items []ShortcutItem
}

ShortcutCategory represents a category of shortcuts

type ShortcutItem

type ShortcutItem struct {
	Key  string
	Desc string
}

ShortcutItem represents a single shortcut

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

Sidebar component for displaying connections, databases and tables

func NewSidebar

func NewSidebar(styles SidebarStyles) Sidebar

NewSidebar creates a new sidebar component

func (*Sidebar) AddConnection

func (s *Sidebar) AddConnection(conn ConnectionItem)

AddConnection adds a connection to the list

func (Sidebar) GetConnections

func (s Sidebar) GetConnections() []ConnectionItem

GetConnections returns the connections list

func (Sidebar) GetCurrentDatabase

func (s Sidebar) GetCurrentDatabase() string

GetCurrentDatabase returns the current active database

func (Sidebar) GetDatabases

func (s Sidebar) GetDatabases() []string

GetDatabases returns the databases list

func (Sidebar) GetSection

func (s Sidebar) GetSection() SidebarSection

GetSection returns the current section

func (Sidebar) GetSelectedConnection

func (s Sidebar) GetSelectedConnection() int

GetSelectedConnection returns the selected connection index

func (Sidebar) GetSelectedDatabase

func (s Sidebar) GetSelectedDatabase() string

GetSelectedDatabase returns the selected database name

func (Sidebar) GetTables

func (s Sidebar) GetTables() []string

GetTables returns the list of table names

func (Sidebar) IsAddConnectionSelected

func (s Sidebar) IsAddConnectionSelected() bool

IsAddConnectionSelected returns true if "+ Add Connection" is selected

func (Sidebar) IsFocused

func (s Sidebar) IsFocused() bool

IsFocused returns if sidebar is focused

func (*Sidebar) SelectTable

func (s *Sidebar) SelectTable(tableName string)

SelectTable sets a table as selected

func (Sidebar) SelectedTable

func (s Sidebar) SelectedTable() string

SelectedTable returns the currently selected table name

func (*Sidebar) SetActiveConnection

func (s *Sidebar) SetActiveConnection(index int)

SetActiveConnection sets which connection is active

func (*Sidebar) SetConnections

func (s *Sidebar) SetConnections(connections []ConnectionItem)

SetConnections sets the list of connections

func (*Sidebar) SetDatabases

func (s *Sidebar) SetDatabases(databases []string, current string)

SetDatabases sets the list of databases

func (*Sidebar) SetFocused

func (s *Sidebar) SetFocused(focused bool)

SetFocused sets the focus state

func (*Sidebar) SetSection

func (s *Sidebar) SetSection(section SidebarSection)

SetSection sets the current section

func (*Sidebar) SetSize

func (s *Sidebar) SetSize(width, height int)

SetSize sets the sidebar dimensions

func (*Sidebar) SetTables

func (s *Sidebar) SetTables(tables []string)

SetTables sets the list of tables

func (*Sidebar) ToggleSection

func (s *Sidebar) ToggleSection()

ToggleSection switches between connections and tables

func (Sidebar) Update

func (s Sidebar) Update(msg tea.Msg) (Sidebar, tea.Cmd)

Update handles input for the sidebar

func (Sidebar) View

func (s Sidebar) View() string

View renders the sidebar

type SidebarSection

type SidebarSection int

SidebarSection represents which section is focused

const (
	SectionConnections SidebarSection = iota
	SectionDatabases
	SectionTables
)

type SidebarStyles

type SidebarStyles struct {
	Normal       lipgloss.Style
	Focused      lipgloss.Style
	Title        lipgloss.Style
	Item         lipgloss.Style
	Selected     lipgloss.Style
	AddButton    lipgloss.Style
	ActiveConn   lipgloss.Style
	InactiveConn lipgloss.Style
}

SidebarStyles holds styling for the sidebar

type TableItem

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

TableItem represents a table in the sidebar

func (TableItem) Description

func (t TableItem) Description() string

func (TableItem) FilterValue

func (t TableItem) FilterValue() string

func (TableItem) Title

func (t TableItem) Title() string

type ViewMode

type ViewMode int

ViewMode determines how results are displayed

const (
	ViewTable ViewMode = iota
	ViewChartBar
	ViewChartLine
	ViewChartPie
)

Jump to

Keyboard shortcuts

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