remove q to quit

This commit is contained in:
2025-07-12 22:25:09 -07:00
parent ac9147ac14
commit f2358a1ab5
6 changed files with 47 additions and 32 deletions

View File

@@ -498,7 +498,7 @@ func max(a, b int) int {
}
func initialModel(dbPath string) model {
db, err := sql.Open("sqlite3", dbPath)
db, err := sql.Open("sqlite", dbPath)
if err != nil {
return model{err: err}
}
@@ -533,7 +533,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Add similar updates for other model types as needed
case tea.KeyMsg:
if msg.String() == "ctrl+c" || msg.String() == "q" {
if msg.String() == "ctrl+c" {
return m, tea.Quit
}
@@ -606,7 +606,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m model) View() string {
if m.err != nil {
return errorStyle.Render(fmt.Sprintf("Error: %v\n\nPress 'q' to quit", m.err))
return errorStyle.Render(fmt.Sprintf("Error: %v\n\nPress 'ctrl+c' to quit", m.err))
}
return m.currentView.View()
}

View File

@@ -17,6 +17,7 @@ type queryModel struct {
columns []string
focusOnInput bool // true = input focused, false = results focused
selectedRow int
errorMsg string // Error message to display
}
func newQueryModel(shared *sharedData) *queryModel {
@@ -42,6 +43,11 @@ func (m *queryModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m *queryModel) handleInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
switch msg.String() {
case "esc":
// Clear error message if present, otherwise go back
if m.errorMsg != "" {
m.errorMsg = ""
return m, nil
}
return m, func() tea.Msg { return switchToTableListMsg{} }
case "tab":
@@ -59,7 +65,9 @@ func (m *queryModel) handleInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
if m.focusOnInput {
// Execute query when input is focused
if err := m.executeQuery(); err != nil {
// TODO: Handle error - could set an error field
m.errorMsg = err.Error()
} else {
m.errorMsg = "" // Clear error on successful query
}
} else {
// View row detail when results are focused
@@ -281,6 +289,15 @@ func (m *queryModel) View() string {
content.WriteString(titleStyle.Render("SQL Query"))
content.WriteString("\n\n")
// Display error modal if there's an error
if m.errorMsg != "" {
errorBox := errorStyle.Render(fmt.Sprintf("Error: %s", m.errorMsg))
content.WriteString(errorBox)
content.WriteString("\n\n")
content.WriteString(helpStyle.Render("esc: dismiss error"))
return content.String()
}
// Display query with cursor and focus indicator
if m.focusOnInput {
content.WriteString("Query: ")

View File

@@ -166,8 +166,7 @@ func (m *rowDetailModel) View() string {
}
content.WriteString("\n")
content.WriteString(helpStyle.Render("↑/↓: select field • enter: edit • esc: back • q: quit"))
content.WriteString(helpStyle.Render("↑/↓: select field • enter: edit • esc: back • ctrl+c: quit"))
return content.String()
}

View File

@@ -221,9 +221,8 @@ func (m *tableDataModel) View() string {
if m.searching {
content.WriteString(helpStyle.Render("Type to search • enter/esc: finish search"))
} else {
content.WriteString(helpStyle.Render("↑/↓: select row • ←/→: page • /: search • enter: view row • esc: back • r: refresh • q: quit"))
content.WriteString(helpStyle.Render("↑/↓: select row • ←/→: page • /: search • enter: view row • esc: back • r: refresh • ctrl+c: quit"))
}
return content.String()
}

View File

@@ -182,7 +182,7 @@ func (m *tableListModel) View() string {
}
if len(m.shared.filteredTables) > visibleCount {
totalPages := (len(m.shared.filteredTables) - 1) / visibleCount + 1
totalPages := (len(m.shared.filteredTables)-1)/visibleCount + 1
content.WriteString(fmt.Sprintf("\nPage %d/%d", m.currentPage+1, totalPages))
}
}
@@ -191,7 +191,7 @@ func (m *tableListModel) View() string {
if m.searching {
content.WriteString(helpStyle.Render("Type to search • enter/esc: finish search"))
} else {
content.WriteString(helpStyle.Render("↑/↓: navigate • ←/→: page • /: search • enter: view • s: SQL • r: refresh • q: quit"))
content.WriteString(helpStyle.Render("↑/↓: navigate • ←/→: page • /: search • enter: view • s: SQL • r: refresh • ctrl+c: quit"))
}
return content.String()