mirror of
https://github.com/taigrr/teaqlite.git
synced 2026-04-02 04:59:03 -07:00
clear filter via esc
This commit is contained in:
@@ -18,6 +18,7 @@ const (
|
||||
// Custom message types
|
||||
type (
|
||||
SwitchToTableListMsg struct{}
|
||||
SwitchToTableListClearMsg struct{} // Switch to table list and clear any filter
|
||||
SwitchToTableDataMsg struct{ TableIndex int }
|
||||
SwitchToRowDetailMsg struct{ RowIndex int }
|
||||
SwitchToRowDetailFromQueryMsg struct{ RowIndex int }
|
||||
@@ -519,6 +520,14 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.currentView = NewTableListModel(m.getSharedData())
|
||||
return m, nil
|
||||
|
||||
case SwitchToTableListClearMsg:
|
||||
shared := m.getSharedData()
|
||||
// Clear any table filter
|
||||
shared.FilteredTables = make([]string, len(shared.Tables))
|
||||
copy(shared.FilteredTables, shared.Tables)
|
||||
m.currentView = NewTableListModel(shared)
|
||||
return m, nil
|
||||
|
||||
case SwitchToTableDataMsg:
|
||||
shared := m.getSharedData()
|
||||
shared.SelectedTable = msg.TableIndex
|
||||
|
||||
@@ -57,7 +57,7 @@ func (m *QueryModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
func (m *QueryModel) handleQueryInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
switch msg.String() {
|
||||
case "esc":
|
||||
return m, func() tea.Msg { return SwitchToTableListMsg{} }
|
||||
return m, func() tea.Msg { return SwitchToTableListClearMsg{} }
|
||||
|
||||
case "enter":
|
||||
if strings.TrimSpace(m.query) != "" {
|
||||
@@ -108,7 +108,7 @@ func (m *QueryModel) handleResultsNavigation(msg tea.KeyMsg) (tea.Model, tea.Cmd
|
||||
switch msg.String() {
|
||||
case "esc", "q":
|
||||
m.gPressed = false
|
||||
return m, func() tea.Msg { return SwitchToTableListMsg{} }
|
||||
return m, func() tea.Msg { return SwitchToTableListClearMsg{} }
|
||||
|
||||
case "g":
|
||||
if m.gPressed {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (m *TableDataModel) handleNavigation(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
switch msg.String() {
|
||||
case "q":
|
||||
m.gPressed = false
|
||||
return m, func() tea.Msg { return SwitchToTableListMsg{} }
|
||||
return m, func() tea.Msg { return SwitchToTableListClearMsg{} }
|
||||
|
||||
case "esc":
|
||||
m.gPressed = false
|
||||
@@ -71,7 +71,7 @@ func (m *TableDataModel) handleNavigation(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
m.filterData()
|
||||
return m, nil
|
||||
}
|
||||
return m, func() tea.Msg { return SwitchToTableListMsg{} }
|
||||
return m, func() tea.Msg { return SwitchToTableListClearMsg{} }
|
||||
|
||||
case "g":
|
||||
if m.gPressed {
|
||||
|
||||
@@ -42,7 +42,14 @@ func (m *TableListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
func (m *TableListModel) handleSearchInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
switch msg.String() {
|
||||
case "esc", "enter":
|
||||
case "esc":
|
||||
m.searching = false
|
||||
// If there's an existing filter, clear it
|
||||
if m.searchInput != "" {
|
||||
m.searchInput = ""
|
||||
m.filterTables()
|
||||
}
|
||||
case "enter":
|
||||
m.searching = false
|
||||
m.filterTables()
|
||||
case "backspace":
|
||||
|
||||
Reference in New Issue
Block a user