mirror of
https://github.com/taigrr/teaqlite.git
synced 2026-04-02 04:59:03 -07:00
fix help properly
This commit is contained in:
@@ -152,15 +152,11 @@ func (m *EditCellModel) View() string {
|
|||||||
content := fmt.Sprintf("%s\n\n", TitleStyle.Render(fmt.Sprintf("Edit Cell: %s", columnName)))
|
content := fmt.Sprintf("%s\n\n", TitleStyle.Render(fmt.Sprintf("Edit Cell: %s", columnName)))
|
||||||
content += fmt.Sprintf("Value: %s\n\n", m.input.View())
|
content += fmt.Sprintf("Value: %s\n\n", m.input.View())
|
||||||
|
|
||||||
var helpText string
|
|
||||||
if m.showFullHelp {
|
if m.showFullHelp {
|
||||||
helpText = m.help.FullHelpView(m.keyMap.FullHelp())
|
content += m.help.FullHelpView(m.keyMap.FullHelp())
|
||||||
} else {
|
} else {
|
||||||
helpText = m.help.ShortHelpView(m.keyMap.ShortHelp())
|
content += m.help.ShortHelpView(m.keyMap.ShortHelp())
|
||||||
// Add ctrl+g to short help
|
|
||||||
helpText += " • " + HelpStyle.Render("ctrl+g: toggle help")
|
|
||||||
}
|
}
|
||||||
content += helpText
|
|
||||||
|
|
||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ type EditCellKeyMap struct {
|
|||||||
LineEnd key.Binding
|
LineEnd key.Binding
|
||||||
DeleteWord key.Binding
|
DeleteWord key.Binding
|
||||||
DeleteChar key.Binding
|
DeleteChar key.Binding
|
||||||
|
ToggleHelp key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultEditCellKeyMap returns the default keybindings for edit cell
|
// DefaultEditCellKeyMap returns the default keybindings for edit cell
|
||||||
@@ -59,12 +60,16 @@ func DefaultEditCellKeyMap() EditCellKeyMap {
|
|||||||
key.WithKeys("backspace"),
|
key.WithKeys("backspace"),
|
||||||
key.WithHelp("backspace", "delete char"),
|
key.WithHelp("backspace", "delete char"),
|
||||||
),
|
),
|
||||||
|
ToggleHelp: key.NewBinding(
|
||||||
|
key.WithKeys("ctrl+g"),
|
||||||
|
key.WithHelp("ctrl+g", "toggle help"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShortHelp returns keybindings to be shown in the mini help view
|
// ShortHelp returns keybindings to be shown in the mini help view
|
||||||
func (k EditCellKeyMap) ShortHelp() []key.Binding {
|
func (k EditCellKeyMap) ShortHelp() []key.Binding {
|
||||||
return []key.Binding{k.Save, k.Cancel}
|
return []key.Binding{k.Save, k.Cancel, k.ToggleHelp}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullHelp returns keybindings for the expanded help view
|
// FullHelp returns keybindings for the expanded help view
|
||||||
@@ -72,6 +77,6 @@ func (k EditCellKeyMap) FullHelp() [][]key.Binding {
|
|||||||
return [][]key.Binding{
|
return [][]key.Binding{
|
||||||
{k.Save, k.Cancel},
|
{k.Save, k.Cancel},
|
||||||
{k.CursorLeft, k.CursorRight, k.WordLeft, k.WordRight},
|
{k.CursorLeft, k.CursorRight, k.WordLeft, k.WordRight},
|
||||||
{k.LineStart, k.LineEnd, k.DeleteWord, k.DeleteChar},
|
{k.LineStart, k.LineEnd, k.DeleteWord, k.DeleteChar, k.ToggleHelp},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,15 +456,11 @@ func (m *QueryModel) View() string {
|
|||||||
if m.FocusOnInput {
|
if m.FocusOnInput {
|
||||||
content.WriteString(HelpStyle.Render("enter: execute • esc: back • ctrl+g: toggle help"))
|
content.WriteString(HelpStyle.Render("enter: execute • esc: back • ctrl+g: toggle help"))
|
||||||
} else {
|
} else {
|
||||||
var helpText string
|
|
||||||
if m.showFullHelp {
|
if m.showFullHelp {
|
||||||
helpText = m.help.FullHelpView(m.keyMap.FullHelp())
|
content.WriteString(m.help.FullHelpView(m.keyMap.FullHelp()))
|
||||||
} else {
|
} else {
|
||||||
helpText = m.help.ShortHelpView(m.keyMap.ShortHelp())
|
content.WriteString(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()
|
return content.String()
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type QueryKeyMap struct {
|
|||||||
GoToStart key.Binding
|
GoToStart key.Binding
|
||||||
GoToEnd key.Binding
|
GoToEnd key.Binding
|
||||||
Back key.Binding
|
Back key.Binding
|
||||||
|
ToggleHelp key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultQueryKeyMap returns the default keybindings for query view
|
// DefaultQueryKeyMap returns the default keybindings for query view
|
||||||
@@ -98,12 +99,16 @@ func DefaultQueryKeyMap() QueryKeyMap {
|
|||||||
key.WithKeys("q"),
|
key.WithKeys("q"),
|
||||||
key.WithHelp("q", "back"),
|
key.WithHelp("q", "back"),
|
||||||
),
|
),
|
||||||
|
ToggleHelp: key.NewBinding(
|
||||||
|
key.WithKeys("ctrl+g"),
|
||||||
|
key.WithHelp("ctrl+g", "toggle help"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShortHelp returns keybindings to be shown in the mini help view
|
// ShortHelp returns keybindings to be shown in the mini help view
|
||||||
func (k QueryKeyMap) ShortHelp() []key.Binding {
|
func (k QueryKeyMap) ShortHelp() []key.Binding {
|
||||||
return []key.Binding{k.Execute, k.Up, k.Down, k.GoToStart, k.GoToEnd, k.EditQuery}
|
return []key.Binding{k.Execute, k.Up, k.Down, k.GoToStart, k.GoToEnd, k.EditQuery, k.ToggleHelp}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullHelp returns keybindings for the expanded help view
|
// FullHelp returns keybindings for the expanded help view
|
||||||
@@ -112,6 +117,6 @@ func (k QueryKeyMap) FullHelp() [][]key.Binding {
|
|||||||
{k.Execute, k.Escape, k.EditQuery, k.Back},
|
{k.Execute, k.Escape, k.EditQuery, k.Back},
|
||||||
{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd},
|
{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd},
|
||||||
{k.CursorLeft, k.CursorRight, k.WordLeft, k.WordRight},
|
{k.CursorLeft, k.CursorRight, k.WordLeft, k.WordRight},
|
||||||
{k.LineStart, k.LineEnd, k.DeleteWord},
|
{k.LineStart, k.LineEnd, k.DeleteWord, k.ToggleHelp},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,15 +181,11 @@ func (m *RowDetailModel) View() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
content.WriteString("\n")
|
content.WriteString("\n")
|
||||||
var helpText string
|
|
||||||
if m.showFullHelp {
|
if m.showFullHelp {
|
||||||
helpText = m.help.FullHelpView(m.keyMap.FullHelp())
|
content.WriteString(m.help.FullHelpView(m.keyMap.FullHelp()))
|
||||||
} else {
|
} else {
|
||||||
helpText = m.help.ShortHelpView(m.keyMap.ShortHelp())
|
content.WriteString(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()
|
return content.String()
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ type RowDetailKeyMap struct {
|
|||||||
Back key.Binding
|
Back key.Binding
|
||||||
GoToStart key.Binding
|
GoToStart key.Binding
|
||||||
GoToEnd key.Binding
|
GoToEnd key.Binding
|
||||||
|
ToggleHelp key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultRowDetailKeyMap returns the default keybindings for row detail
|
// DefaultRowDetailKeyMap returns the default keybindings for row detail
|
||||||
@@ -47,18 +48,22 @@ func DefaultRowDetailKeyMap() RowDetailKeyMap {
|
|||||||
key.WithKeys("G"),
|
key.WithKeys("G"),
|
||||||
key.WithHelp("G", "go to end"),
|
key.WithHelp("G", "go to end"),
|
||||||
),
|
),
|
||||||
|
ToggleHelp: key.NewBinding(
|
||||||
|
key.WithKeys("ctrl+g"),
|
||||||
|
key.WithHelp("ctrl+g", "toggle help"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShortHelp returns keybindings to be shown in the mini help view
|
// ShortHelp returns keybindings to be shown in the mini help view
|
||||||
func (k RowDetailKeyMap) ShortHelp() []key.Binding {
|
func (k RowDetailKeyMap) ShortHelp() []key.Binding {
|
||||||
return []key.Binding{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd, k.Back}
|
return []key.Binding{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd, k.Back, k.ToggleHelp}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullHelp returns keybindings for the expanded help view
|
// FullHelp returns keybindings for the expanded help view
|
||||||
func (k RowDetailKeyMap) FullHelp() [][]key.Binding {
|
func (k RowDetailKeyMap) FullHelp() [][]key.Binding {
|
||||||
return [][]key.Binding{
|
return [][]key.Binding{
|
||||||
{k.Up, k.Down, k.Enter},
|
{k.Up, k.Down, k.Enter},
|
||||||
{k.Escape, k.Back, k.GoToStart, k.GoToEnd},
|
{k.Escape, k.Back, k.GoToStart, k.GoToEnd, k.ToggleHelp},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -445,15 +445,11 @@ func (m *TableDataModel) View() string {
|
|||||||
if m.searching {
|
if m.searching {
|
||||||
content.WriteString(HelpStyle.Render("Type to search • enter/esc: finish search"))
|
content.WriteString(HelpStyle.Render("Type to search • enter/esc: finish search"))
|
||||||
} else {
|
} else {
|
||||||
var helpText string
|
|
||||||
if m.showFullHelp {
|
if m.showFullHelp {
|
||||||
helpText = m.help.FullHelpView(m.keyMap.FullHelp())
|
content.WriteString(m.help.FullHelpView(m.keyMap.FullHelp()))
|
||||||
} else {
|
} else {
|
||||||
helpText = m.help.ShortHelpView(m.keyMap.ShortHelp())
|
content.WriteString(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()
|
return content.String()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type TableDataKeyMap struct {
|
|||||||
GoToEnd key.Binding
|
GoToEnd key.Binding
|
||||||
Refresh key.Binding
|
Refresh key.Binding
|
||||||
SQLMode key.Binding
|
SQLMode key.Binding
|
||||||
|
ToggleHelp key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultTableDataKeyMap returns the default keybindings for table data
|
// DefaultTableDataKeyMap returns the default keybindings for table data
|
||||||
@@ -72,12 +73,16 @@ func DefaultTableDataKeyMap() TableDataKeyMap {
|
|||||||
key.WithKeys("s"),
|
key.WithKeys("s"),
|
||||||
key.WithHelp("s", "SQL mode"),
|
key.WithHelp("s", "SQL mode"),
|
||||||
),
|
),
|
||||||
|
ToggleHelp: key.NewBinding(
|
||||||
|
key.WithKeys("ctrl+g"),
|
||||||
|
key.WithHelp("ctrl+g", "toggle help"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShortHelp returns keybindings to be shown in the mini help view
|
// ShortHelp returns keybindings to be shown in the mini help view
|
||||||
func (k TableDataKeyMap) ShortHelp() []key.Binding {
|
func (k TableDataKeyMap) ShortHelp() []key.Binding {
|
||||||
return []key.Binding{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd, k.Search}
|
return []key.Binding{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd, k.Search, k.ToggleHelp}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullHelp returns keybindings for the expanded help view
|
// FullHelp returns keybindings for the expanded help view
|
||||||
@@ -85,6 +90,6 @@ func (k TableDataKeyMap) FullHelp() [][]key.Binding {
|
|||||||
return [][]key.Binding{
|
return [][]key.Binding{
|
||||||
{k.Up, k.Down, k.Left, k.Right},
|
{k.Up, k.Down, k.Left, k.Right},
|
||||||
{k.Enter, k.Search, k.Escape, k.Back},
|
{k.Enter, k.Search, k.Escape, k.Back},
|
||||||
{k.GoToStart, k.GoToEnd, k.Refresh, k.SQLMode},
|
{k.GoToStart, k.GoToEnd, k.Refresh, k.SQLMode, k.ToggleHelp},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,15 +411,11 @@ func (m *TableListModel) View() string {
|
|||||||
if m.searching {
|
if m.searching {
|
||||||
content.WriteString(HelpStyle.Render("Type to search • enter/esc: finish search"))
|
content.WriteString(HelpStyle.Render("Type to search • enter/esc: finish search"))
|
||||||
} else {
|
} else {
|
||||||
var helpText string
|
|
||||||
if m.showFullHelp {
|
if m.showFullHelp {
|
||||||
helpText = m.help.FullHelpView(m.keyMap.FullHelp())
|
content.WriteString(m.help.FullHelpView(m.keyMap.FullHelp()))
|
||||||
} else {
|
} else {
|
||||||
helpText = m.help.ShortHelpView(m.keyMap.ShortHelp())
|
content.WriteString(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()
|
return content.String()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type TableListKeyMap struct {
|
|||||||
GoToEnd key.Binding
|
GoToEnd key.Binding
|
||||||
Refresh key.Binding
|
Refresh key.Binding
|
||||||
SQLMode key.Binding
|
SQLMode key.Binding
|
||||||
|
ToggleHelp key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultTableListKeyMap returns the default keybindings for table list
|
// DefaultTableListKeyMap returns the default keybindings for table list
|
||||||
@@ -67,12 +68,16 @@ func DefaultTableListKeyMap() TableListKeyMap {
|
|||||||
key.WithKeys("s"),
|
key.WithKeys("s"),
|
||||||
key.WithHelp("s", "SQL mode"),
|
key.WithHelp("s", "SQL mode"),
|
||||||
),
|
),
|
||||||
|
ToggleHelp: key.NewBinding(
|
||||||
|
key.WithKeys("ctrl+g"),
|
||||||
|
key.WithHelp("ctrl+g", "toggle help"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShortHelp returns keybindings to be shown in the mini help view
|
// ShortHelp returns keybindings to be shown in the mini help view
|
||||||
func (k TableListKeyMap) ShortHelp() []key.Binding {
|
func (k TableListKeyMap) ShortHelp() []key.Binding {
|
||||||
return []key.Binding{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd, k.Search}
|
return []key.Binding{k.Up, k.Down, k.Enter, k.GoToStart, k.GoToEnd, k.Search, k.ToggleHelp}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullHelp returns keybindings for the expanded help view
|
// FullHelp returns keybindings for the expanded help view
|
||||||
@@ -80,6 +85,6 @@ func (k TableListKeyMap) FullHelp() [][]key.Binding {
|
|||||||
return [][]key.Binding{
|
return [][]key.Binding{
|
||||||
{k.Up, k.Down, k.Left, k.Right},
|
{k.Up, k.Down, k.Left, k.Right},
|
||||||
{k.Enter, k.Search, k.Escape, k.Refresh},
|
{k.Enter, k.Search, k.Escape, k.Refresh},
|
||||||
{k.GoToStart, k.GoToEnd, k.SQLMode},
|
{k.GoToStart, k.GoToEnd, k.SQLMode, k.ToggleHelp},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user