mirror of
https://github.com/taigrr/teaqlite.git
synced 2026-04-02 04:59:03 -07:00
jerry-rig a help toggle cmd
This commit is contained in:
@@ -12,15 +12,16 @@ import (
|
||||
)
|
||||
|
||||
type TableDataModel struct {
|
||||
Shared *SharedData
|
||||
searchInput textinput.Model
|
||||
searching bool
|
||||
selectedRow int
|
||||
gPressed bool
|
||||
keyMap TableDataKeyMap
|
||||
help help.Model
|
||||
focused bool
|
||||
id int
|
||||
Shared *SharedData
|
||||
searchInput textinput.Model
|
||||
searching bool
|
||||
selectedRow int
|
||||
gPressed bool
|
||||
keyMap TableDataKeyMap
|
||||
help help.Model
|
||||
showFullHelp bool
|
||||
focused bool
|
||||
id int
|
||||
}
|
||||
|
||||
// TableDataOption is a functional option for configuring TableDataModel
|
||||
@@ -93,6 +94,10 @@ func (m *TableDataModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
var cmds []tea.Cmd
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case ToggleHelpMsg:
|
||||
m.showFullHelp = !m.showFullHelp
|
||||
return m, nil
|
||||
|
||||
case tea.KeyMsg:
|
||||
if m.searching {
|
||||
return m.handleSearchInput(msg)
|
||||
@@ -151,20 +156,20 @@ func (m *TableDataModel) handleNavigation(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
|
||||
case key.Matches(msg, m.keyMap.GoToStart):
|
||||
if m.gPressed {
|
||||
// Second g - go to absolute beginning
|
||||
// Second g - go to absolute beginning (gg pattern like vim)
|
||||
m.Shared.CurrentPage = 0
|
||||
m.Shared.LoadTableData()
|
||||
m.filterData()
|
||||
m.selectedRow = 0
|
||||
m.gPressed = false
|
||||
} else {
|
||||
// First g - wait for second g
|
||||
// First g - wait for second g to complete gg sequence
|
||||
m.gPressed = true
|
||||
}
|
||||
return m, nil
|
||||
|
||||
case key.Matches(msg, m.keyMap.GoToEnd):
|
||||
// Go to absolute end
|
||||
// Go to absolute end (G pattern like vim)
|
||||
maxPage := (m.Shared.TotalRows - 1) / PageSize
|
||||
m.Shared.CurrentPage = maxPage
|
||||
m.Shared.LoadTableData()
|
||||
@@ -440,7 +445,15 @@ func (m *TableDataModel) View() string {
|
||||
if m.searching {
|
||||
content.WriteString(HelpStyle.Render("Type to search • enter/esc: finish search"))
|
||||
} else {
|
||||
content.WriteString(m.help.View(m.keyMap))
|
||||
var helpText string
|
||||
if m.showFullHelp {
|
||||
helpText = m.help.FullHelpView(m.keyMap.FullHelp())
|
||||
} else {
|
||||
helpText = m.help.ShortHelpView(m.keyMap.ShortHelp())
|
||||
// Add ctrl+g to short help
|
||||
helpText += " • " + HelpStyle.Render("ctrl+g: toggle help")
|
||||
}
|
||||
content.WriteString(helpText)
|
||||
}
|
||||
|
||||
return content.String()
|
||||
|
||||
Reference in New Issue
Block a user