MCPcopy
hub / github.com/ddworken/hishtory / initialModel

Function initialModel

client/tui/tui.go:130–158  ·  view source on GitHub ↗
(ctx context.Context, shellName, initialQuery string)

Source from the content-addressed store, hash-verified

128}
129
130func initialModel(ctx context.Context, shellName, initialQuery string) model {
131 s := spinner.New()
132 s.Spinner = spinner.Dot
133 s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
134 queryInput := textinput.New()
135 cfg := hctx.GetConf(ctx)
136 defaultFilter := cfg.DefaultFilter
137 if defaultFilter != "" {
138 queryInput.Prompt = "[" + defaultFilter + "] "
139 }
140 queryInput.PromptStyle = queryInput.PlaceholderStyle
141 if defaultFilter == "" {
142 queryInput.Placeholder = "ls"
143 }
144 queryInput.Focus()
145 queryInput.CharLimit = 200
146 width, _, err := getTerminalSize()
147 if err == nil {
148 queryInput.Width = width
149 } else {
150 hctx.GetLogger().Warnf("getTerminalSize() return err=%#v, defaulting queryInput to a width of 50", err)
151 queryInput.Width = 50
152 }
153 if initialQuery != "" {
154 queryInput.SetValue(initialQuery)
155 }
156 CURRENT_QUERY_FOR_HIGHLIGHTING = initialQuery
157 return model{ctx: ctx, spinner: s, isLoading: true, table: nil, tableEntries: []*data.HistoryEntry{}, runQuery: &initialQuery, queryInput: queryInput, help: help.New(), shellName: shellName, hasFinishedFirstLoad: false}
158}
159
160func (m model) Init() tea.Cmd {
161 return m.spinner.Tick

Callers 1

TuiQueryFunction · 0.85

Calls 4

GetConfFunction · 0.92
GetLoggerFunction · 0.92
getTerminalSizeFunction · 0.85
FocusMethod · 0.80

Tested by

no test coverage detected