mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-18 11:06:41 +02:00
add forceComapctMode config entry (#237)
This commit is contained in:
parent
9b8baa8274
commit
ad8775c334
@ -210,6 +210,18 @@ var setColorSchemeBorderColor = &cobra.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var toggleCompactMode = &cobra.Command{
|
||||||
|
Use: "toggle-compact-mode",
|
||||||
|
Short: "Toggle compact mode switching it on or off",
|
||||||
|
Args: cobra.ExactArgs(0),
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
ctx := hctx.MakeContext()
|
||||||
|
config := hctx.GetConf(ctx)
|
||||||
|
config.ForceCompactMode = !config.ForceCompactMode
|
||||||
|
lib.CheckFatalError(hctx.SetConfig(config))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func validateColor(color string) error {
|
func validateColor(color string) error {
|
||||||
if !strings.HasPrefix(color, "#") || len(color) != 7 {
|
if !strings.HasPrefix(color, "#") || len(color) != 7 {
|
||||||
return fmt.Errorf("color %q is invalid, it should be a hexadecimal color like #663399", color)
|
return fmt.Errorf("color %q is invalid, it should be a hexadecimal color like #663399", color)
|
||||||
@ -242,6 +254,7 @@ func init() {
|
|||||||
configSetCmd.AddCommand(setColorSchemeCmd)
|
configSetCmd.AddCommand(setColorSchemeCmd)
|
||||||
configSetCmd.AddCommand(setDefaultFilterCommand)
|
configSetCmd.AddCommand(setDefaultFilterCommand)
|
||||||
configSetCmd.AddCommand(setAiCompletionEndpoint)
|
configSetCmd.AddCommand(setAiCompletionEndpoint)
|
||||||
|
configSetCmd.AddCommand(toggleCompactMode)
|
||||||
setColorSchemeCmd.AddCommand(setColorSchemeSelectedText)
|
setColorSchemeCmd.AddCommand(setColorSchemeSelectedText)
|
||||||
setColorSchemeCmd.AddCommand(setColorSchemeSelectedBackground)
|
setColorSchemeCmd.AddCommand(setColorSchemeSelectedBackground)
|
||||||
setColorSchemeCmd.AddCommand(setColorSchemeBorderColor)
|
setColorSchemeCmd.AddCommand(setColorSchemeBorderColor)
|
||||||
|
@ -189,6 +189,8 @@ type ClientConfig struct {
|
|||||||
// Custom columns
|
// Custom columns
|
||||||
CustomColumns []CustomColumnDefinition `json:"custom_columns"`
|
CustomColumns []CustomColumnDefinition `json:"custom_columns"`
|
||||||
// Whether this is an offline instance of hishtory with no syncing
|
// Whether this is an offline instance of hishtory with no syncing
|
||||||
|
ForceCompactMode bool `json:"force_compact_mode"`
|
||||||
|
// Whether this is an offline instance of hishtory with no syncing
|
||||||
IsOffline bool `json:"is_offline"`
|
IsOffline bool `json:"is_offline"`
|
||||||
// Whether duplicate commands should be displayed
|
// Whether duplicate commands should be displayed
|
||||||
FilterDuplicateCommands bool `json:"filter_duplicate_commands"`
|
FilterDuplicateCommands bool `json:"filter_duplicate_commands"`
|
||||||
|
@ -94,6 +94,9 @@ type model struct {
|
|||||||
|
|
||||||
// The currently executing shell. Defaults to bash if not specified. Used for more precise AI suggestions.
|
// The currently executing shell. Defaults to bash if not specified. Used for more precise AI suggestions.
|
||||||
shellName string
|
shellName string
|
||||||
|
|
||||||
|
// Compacting TUI config
|
||||||
|
compactTUIflag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type doneDownloadingMsg struct{}
|
type doneDownloadingMsg struct{}
|
||||||
@ -122,7 +125,8 @@ func initialModel(ctx context.Context, shellName, initialQuery string) model {
|
|||||||
s.Spinner = spinner.Dot
|
s.Spinner = spinner.Dot
|
||||||
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
|
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
|
||||||
queryInput := textinput.New()
|
queryInput := textinput.New()
|
||||||
defaultFilter := hctx.GetConf(ctx).DefaultFilter
|
cfg := hctx.GetConf(ctx)
|
||||||
|
defaultFilter := cfg.DefaultFilter
|
||||||
if defaultFilter != "" {
|
if defaultFilter != "" {
|
||||||
queryInput.Prompt = "[" + defaultFilter + "] "
|
queryInput.Prompt = "[" + defaultFilter + "] "
|
||||||
}
|
}
|
||||||
@ -143,7 +147,7 @@ func initialModel(ctx context.Context, shellName, initialQuery string) model {
|
|||||||
queryInput.SetValue(initialQuery)
|
queryInput.SetValue(initialQuery)
|
||||||
}
|
}
|
||||||
CURRENT_QUERY_FOR_HIGHLIGHTING = initialQuery
|
CURRENT_QUERY_FOR_HIGHLIGHTING = initialQuery
|
||||||
return model{ctx: ctx, spinner: s, isLoading: true, table: nil, tableEntries: []*data.HistoryEntry{}, runQuery: &initialQuery, queryInput: queryInput, help: help.New(), shellName: shellName}
|
return model{ctx: ctx, spinner: s, isLoading: true, table: nil, tableEntries: []*data.HistoryEntry{}, runQuery: &initialQuery, queryInput: queryInput, help: help.New(), shellName: shellName, compactTUIflag: cfg.ForceCompactMode}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) Init() tea.Cmd {
|
func (m model) Init() tea.Cmd {
|
||||||
@ -395,15 +399,15 @@ func (m model) View() string {
|
|||||||
additionalMessages = append(additionalMessages, fmt.Sprintf("%s Executing search query...", m.spinner.View()))
|
additionalMessages = append(additionalMessages, fmt.Sprintf("%s Executing search query...", m.spinner.View()))
|
||||||
}
|
}
|
||||||
additionalMessagesStr := strings.Join(additionalMessages, "\n") + "\n"
|
additionalMessagesStr := strings.Join(additionalMessages, "\n") + "\n"
|
||||||
if isExtraCompactHeightMode() {
|
if isExtraCompactHeightMode() || m.compactTUIflag {
|
||||||
additionalMessagesStr = "\n"
|
additionalMessagesStr = "\n"
|
||||||
}
|
}
|
||||||
helpView := m.help.View(loadedKeyBindings)
|
helpView := m.help.View(loadedKeyBindings)
|
||||||
if isExtraCompactHeightMode() {
|
if isExtraCompactHeightMode() || m.compactTUIflag {
|
||||||
helpView = ""
|
helpView = ""
|
||||||
}
|
}
|
||||||
additionalSpacing := "\n"
|
additionalSpacing := "\n"
|
||||||
if isCompactHeightMode() {
|
if isCompactHeightMode() || m.compactTUIflag {
|
||||||
additionalSpacing = ""
|
additionalSpacing = ""
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s%s%s%sSearch Query: %s\n%s%s\n", additionalSpacing, additionalMessagesStr, m.banner, additionalSpacing, m.queryInput.View(), additionalSpacing, renderNullableTable(m, helpView)) + helpView
|
return fmt.Sprintf("%s%s%s%sSearch Query: %s\n%s%s\n", additionalSpacing, additionalMessagesStr, m.banner, additionalSpacing, m.queryInput.View(), additionalSpacing, renderNullableTable(m, helpView)) + helpView
|
||||||
|
Loading…
x
Reference in New Issue
Block a user